赞
踩
效果展示:
HTML
<view class="slides">
<swiper autoplay indicator-dots circular>
<swiper-item wx:for="{{swiperList}}" wx:key="index">
<navigator url="{{item.imgUrl}}" open-type="switchTab" hover-class="other-navigator-hover">
<image mode="widthFix" src="{{item.imgSrc}}" ></image>
</navigator>
</swiper-item>
</swiper>
</view>
JS
Page({ data: { swiperList:[], }, getSwiper(){ let that = this; wx.request({ url:"xxx", success(res){ console.log("res") if(res.data.code===0){ that.setData({ swiperList:res.data.data.swiperList }) } }, fail(res){ console.log("res") //假数据 let swiperList = [ {imgSrc:"./img/1.png",//图片路径 imgUrl:"../more/more"//跳转页面路径 }, {imgSrc:"./img/2.png", imgUrl:"../search/search" } ] that.setData ({ swiperList:swiperList }) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getSwiper() })
可供参考文件
swiper的参数官方文档
navigator的参数官方文档
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。