-
在页面的 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
相关推荐
tcdos1 天前
不止扫码 — 微信生态深度融合(登录 + 支付 + 消息)小徐_23332 天前
Wot UI 2.2.0 发布:Button 新增 subtle,VideoPreview 预览体验继续增强蜗牛前端4 天前
codex 全流程开发上线的高颜值礼簿小程序爱勇宝8 天前
我想认真做一件小事:让孩子和家长更好地互动唯火锅不可辜负8 天前
避坑指南:iOS 下 scroll-view 嵌套 fixed 布局的“翻车”现场与修复didiplus8 天前
运维人的随身神器:我把25个常用工具塞进了微信小程序张居斜9 天前
Obsidian + Claude Code + 微信AI,我把这三个系统缝进了一个软件一份执念9 天前
uni-app 小程序分包限制处理与主包体积优化实战一份执念9 天前
ECharts 安装与使用完全指南:从全量引入到小程序分包优化skiyee10 天前
🔥UniApp 仅需 5 行代码!实现所有页面中控制应用主题变化