-
在页面的 WXML 文件中,使用 swiper 组件来实现轮播图:
-
在上述代码中,bannerList 是一个数组,包含了轮播图的数据,每个数据对象需要有一个 imageUrl 字段,表示图片的地址。
-
indicator-dots 设置为 true 可显示轮播图的指示点。
-
autoplay 设置为 true 可自动播放轮播图。
-
circular 设置为 true 可实现循环播放。
-
js文件
Page({
data: {
bannerList: [],
indicatorDots: true,
vertical: false,
autoplay: true,
interval: 2000,
duration: 500,
},
onLoad() {
// 获取轮播图的数据,可以通过接口请求或本地数据
// 将数据设置到 bannerList 数组中
},
// 点击轮播图跳转
onSwiperTap(e) {
let url = e.target.dataset.item.articleUrl
wx.navigateTo({
url: '../article/index?url='+url,
})},})
-
新建一个article文件夹
-
wxml页面中
-
-
js文件中
Page({
data: {
url: ""
},
onLoad: function (options) {
console.log(options,'kkkkkkk')
this.setData({
url: options.url,
})
}
})
微信小程序 轮播图且跳转微信公众号文章
皮卡穆2023-12-14 8:01
相关推荐
不如摸鱼去1 小时前
Wot UI 2.1.0 发布:ConfigProvider 全局配置能力升级这是个栗子4 小时前
微信小程序开发(九)- uni-app微信小程序商城TuCoder5 小时前
景区导览小程序功能选型指南:刚需配置、增值功能与技术避坑要点小羊Yveesss8 小时前
2026年知识付费小程序多少钱一个?一只皮卡皮卡丘8 小时前
微信小程序tab页苹果显示安卓不显示的问题六月的可乐8 小时前
【干货】小程序虚拟瀑布流探索小结前端 贾公子1 天前
小程序蓝牙打印探索与实践(上)拙慕JULY1 天前
小程序返回 base64 文件报错dh131222505251 天前
按月季度销售业绩核算小程序拙慕JULY1 天前
微信小程序自定义标题背景色