微信小程序之swiper


swiper

滑塊視圖容器

 

wxml 代碼如下:

 

<swiper indicator="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
     <block wx:for="{{imgUrls}}">
       <swiper-item>
          <image src="{{item}}" class="slide-image" width="355" height="150"/>
      </swiper-item>    
    </block>
</swiper>    

<button bindtap="changeIndicatorDots"> indicator-dots </button>
<button bindtap="changeAutoplay"> autoplay </button>
<slider bindchange="intervalChange" show-value min="500" max="2000"/> interval
<slider bindchange="durationChange" show-value min="1000" max="10000"/> duration

 

js代碼如下:

Page({
  data: {
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: false,
    autoplay: false,
    interval: 5000,
    duration: 1000
  },
  changeIndicatorDots: function(e) {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  changeAutoplay: function(e) {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },
  intervalChange: function(e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange: function(e) {
    this.setData({
      duration: e.detail.value
    })
  }
})

 

autoplay:是否自動播放 默認值:false false/true

indicator-dots: 是否顯示面板指示點 默認值:false false/true

indicator-color:提示點顏色 默認值:rgba(0, 0, 0, .3)

indicator-active-color:當前提示點顏色 默認值:#000000

current:當前的item的index

current-item-id:當前所在滑塊的 item-id ,不能與 current 被同時指定

interval:自動切換時間間隔 默認值:5000

duration:切換動畫時長 默認值:500

circular :銜接播放(無縫輪播)默認值:false true/false

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM