<swiper class=“indexbanner” indicator-dots autoplay circular>
<block wx:for="{{IndexBannerUrl}}">
<swiper-item>
<image src="{{item.url}}" class=‘indexbanner-image’ mode=‘widthFix’ />
</swiper-item>
</block>
</swiper>
IndexBannerUrl: [
{
link: ‘/pages/index/index’,
url: ‘…/…/images/1.jpg’
}, {
link: ‘/pages/logs/logs’,
url: ‘…/…/images/2.jpg’
}, {
link: ‘/pages/test/test’,
url: ‘…/…/images/3.jpg’
}
],
【跳转外链】
不支持跳转外部链接
【跳转到其他page】
image添加bindtap
<image src="{{item.url}}" class=‘indexbanner-image’ data-link=’{{item.link}}’ bindtap=“bindViewTap” mode=‘widthFix’ />
Page({
bindViewTap:function(event){
wx.navigateTo({
url: event.currentTarget.dataset.link // 页面跳转地址
})
}
})
Page({
data: {
IndexBannerUrl: [
{
link: ‘/pages/index/index’,
url: ‘…/…/images/IndexBanner1.jpg’
}, {
link: ‘/pages/logs/logs’,
url: ‘…/…/images/IndexBanner2.jpg’
}, {
link: ‘/pages/test/test’,
url: ‘…/…/images/IndexBanner3.jpg’
}
]
},
bindViewTap: function (event) {
wx.navigateTo({
url: event.currentTarget.dataset.link // 页面跳转地址
})
},
<view class=“body”>
<swiper class=“indexbanner” indicator-dots autoplay circular>
<block wx:for="{{IndexBannerUrl}}">
<swiper-item>
<image src="{{item.url}}" class=“indexbanner-image” mode=“widthFix” data-link="{{item.link}}" bindtap=“bindViewTap” />
</swiper-item>
</block>
</swiper>
123123
</view>
老铁,不起作用啊。点了没反应