首先在wxml中添加view
<view class="page">
<view>
<swiper indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<block wx:for="{{imgs}}">
<swiper-item>
<image src="{{item}}" class="pic" />
</swiper-item>
</block>
</swiper>
</view>
然后在js中为banner添加数据源:
Page({
/**
* 页面的初始数据
*/
data: {
imgs: ["../../images/a1.jpg","../../images/a2.jpg","../../images/a2.jpg"]
},
})