027-87227388

微信小程序swiper的使用

发布时间:2020-10-30 浏览:1230

  微信小程序在插入轮播图时需要用到swiper滑块视图容器,

  swiper 里只能放置swiper-item(插槽)组件,否则会导致未定义的行为。

<view>
    <image class="top-theme" src="{{themeA.entrance_img}}"></image>
    <swiper class="swiper-img"
            indicator-dots="{{true}}"
            indicator-active-color="#157658"
            circular
            autoplay
            interval="2000">
        <block wx:for="{{bannerB[0].items}}" wx:key="key">
            <swiper-item>
                <image class="swiper-img" src="{{item.img}}"></image>
            </swiper-item>
        </block>
    </swiper>
</view>

indicator-dots="{{true}}" :显示面板指示点

indicator-active-color="#157658" :设置选中的指示点颜色

circular:循环轮播
autoplay:自动切换
interval="2000":自动切换间隔时间、

示例: