ionic 圖片輪播問題,ionic圖片輪播

來源:互聯網
上載者:User

ionic 圖片輪播問題,ionic圖片輪播

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              });21 22 23          }

注入方式如下:


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


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

……

……

}

})();

 

 

 三、使用$ionicSlideBoxDelegate.loop(true)會出現一個至今也沒有想明白的問題:載入兩張圖片時會顯示四張,也就是說會重複兩張,其他的情況均是正常的。所以我最後的解決辦法只能是根據官方文檔實現手動輪播了……

 



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.