Home > Web Front-end > HTML Tutorial > ionic 图片轮播问题_html/css_WEB-ITnose

ionic 图片轮播问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:17:36
Original
1055 people have browsed it

1、使用ion-slide可以实现图片轮播,但是如果在html中仅仅增加ion-slide是远远不够的,会出现两个问题:

(注:使用的是angularjs。首先需要在,js文件中注入:$ionicSlideBoxDelegate)

一、有时候会出现图片无法加载出来。解决办法是:

在相应的controller文件增加 $ionicSlideBoxDelegate.update(); 

二、轮播至最后一个不轮播的问题,解决的办法是:

在相应的controller文件增加 $ionicSlideBoxDelegate.loop(true);

代码如下:

 1 function getMessageInface() { 2              vm.condition = { //入参 3                  "sysid": 1000, 4 "token": "sfiodfndsig" 5  }; 6 Service.post('advertisement', 'findEffectiveDataInfo', vm.condition).then(function(data) { 7 8  console.log(data) 9 vm.ADlists = data;10 angular.forEach(vm.ADlists, function(index) {11 // statements12 // console.log("循环增加imgurl");13 if (index.pic.indexOf("http") < 0) {14 index.pic = vm.imgUrl + index.pic;15 // console.log(index.pic)16  }17  });18 $ionicSlideBoxDelegate.loop(true); //解决轮播至最后一个不轮播的问题19 $ionicSlideBoxDelegate.update(); //解决图片加载不出来的问题20  });212223 }
Copy after login

注入方式如下:

Copy after login
Copy after login

(function() {
angular.module('app').controller('goodsListCtrl', goodsListCtrl);
goodsListCtrl.$inject = ['$scope', '$state', 'Service', '$stateParams', '$localStorage', '$ionicSlideBoxDelegate', '$ionicPopup'];

Copy after login
Copy after login

function goodsListCtrl($scope, $state, Service, $stateParams, $localStorage, $ionicSlideBoxDelegate, $ionicPopup) {
var vm = this;

……

……

}

})();

 
Copy after login

三、使用$ionicSlideBoxDelegate.loop(true)会出现一个至今也没有想明白的问题:加载两张图片时会显示四张,也就是说会重复两张,其他的情况均是正常的。所以我最后的解决办法只能是根据官方文档实现手动轮播了……

<br /><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template