微信小程序——輪播圖實現


小程序的輪播圖,也就是他其中的一個控件可以算是直接上代碼:

這是WXML 頁面 代碼:

  <view class='carousel_div'>
    <swiper class="swiper" indicator-dots="true" autoplay="true" interval="5000" duration="1000">
      <block wx:for="{{commodity_info.LogoPaths}}" wx:for-index="index" wx:key="">

        <swiper-item>
          <image src="{{LogoIp}}{{item}}" class="slide-image" mode='aspectFill' />
        </swiper-item>
      </block>
    </swiper>
  </view>

當然還有一些參數:indicator-dots 是否顯示指視點,ndicator-color知識點的顏色 ,indicator-active-color被選中的知識點顏色,autoplay自動播放,interval時隔,duration滑動時長。

接下來是wxss 的樣式(可以自己調一下):

/* 輪播圖樣式 */

.carousel_div {
  position: relative;
  width: 100%;
  height: 40%;
}

.swiper {
  position: absolute;
  height: 100%;
  width: 100%;
}

.swiper image {
  height: 100%;
  width: 100%;
}

然后 js 頁中,就在data中 隨便寫個字典就可以  key:option  value:圖片地址。。 就可以

(本人頁面使用,需要可以自己拿走,詳細屬性可以查看小程序API    https://mp.weixin.qq.com/debug/wxadoc/dev/component/swiper.html)


免責聲明!

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



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