首页 > 代码库 > 【微信小程序】:实现轮播图3秒滚动

【微信小程序】:实现轮播图3秒滚动

wxml模板:(数据一维数组)

<scroll-view  scroll-y="true">
      <swiper autoplay="auto" interval="3000" duration="500">
          <block wx:for="{{home_pics}}"  wx:for-index="index">
              <swiper-item>
                  <view class="ar_coverpath">
                    <image src="{{home_pics[index]}}" mode="aspectFill"/>
                </view>
              </swiper-item>
          </block>
      </swiper>
    </scroll-view>

wxml模板:(数据二维数组)

<scroll-view  scroll-y="true" style="height:{{scrollHeight}}px;" 
        class="list" bindscrolltolower="bindDownLoad" bindscroll="scroll" bindscrolltoupper="refresh">
    <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
        <block wx:for="{{ad_list}}" wx:for-item="item" wx:for-index="index">
            <swiper-item>
                <image src="{{item.ad_file}}" class="slide-image" style="height:{{windowWidth * 0.375}}px !important"/>
            </swiper-item>
        </block>
    </swiper>
</scroll-view>

 

【微信小程序】:实现轮播图3秒滚动