微信小程序之輪播圖

swiper滑塊視圖容器

swiper滑塊視圖容器用來在指定區(qū)域內(nèi)切換內(nèi)容的顯示,常用于制作海報(bào)輪播圖效果和頁(yè)簽內(nèi)容的切換效果,它的屬性如下

屬性名 類型 默認(rèn)值 說明 最低版本
indicator-dots Boolean false 是否顯示面板指示點(diǎn)
indicator-color Color rgba(0, 0, 0, .3) 指示點(diǎn)顏色 1.1.0
indicator-active-color Color #000000 當(dāng)前選中的指示點(diǎn)顏色 1.1.0
autoplay Boolean false 是否自動(dòng)切換
current Number 0 當(dāng)前所在滑塊的 index
current-item-id String "" 當(dāng)前所在滑塊的 item-id ,不能與 current 被同時(shí)指定 1.9.0
interval Number 5000 自動(dòng)切換時(shí)間間隔
duration Number 500 滑動(dòng)動(dòng)畫時(shí)長(zhǎng)
circular Boolean false 是否采用銜接滑動(dòng)
vertical Boolean false 滑動(dòng)方向是否為縱向
previous-margin String "0px" 前邊距,可用于露出前一項(xiàng)的一小部分,接受 px 和 rpx 值 1.9.0
next-margin String "0px" 后邊距,可用于露出后一項(xiàng)的一小部分,接受 px 和 rpx 值 1.9.0
display-multiple-items Number 1 同時(shí)顯示的滑塊數(shù)量 [1.9.0]

效果如圖

wxml文件

<!--pages/one/one.wxml-->
<view class='haibao'>
  <swiper 
  indicator-dots='{{indicationDots}}'
   autoplay='{{autoplay}}' 
   interval='{{interval}}' 
   duration='{{duration}}' 
   circular='{{circular}}' >
 <block wx:for="{{imgurls}}" wx:key="key">
    <swiper-item>
    <image src="{{item}}" class="side-image" style="width:100%"></image>
    </swiper-item>
 </block>
  </swiper>
</view>

js文件

Page({

  /**
   * 頁(yè)面的初始數(shù)據(jù)
   */
  data: {
    indicationDots:true,
    autoplay:true,
    interval:5000,
    duration:1000,
    circular:true,
    
    imgurls:["../images/1.jpg","../images/2.jpg","../images/3.jpg"]

  },
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容