微信小程序页面传递循环列表数据

2024-10-13 09:42:35

1、打开开发者工具,在项目pages文件夹下,新建目录,在目录内新建mypage,并在app.json中将mypage设为第一页面

微信小程序页面传递循环列表数据

3、在mypage.wxss中写代码如下:.item{width: 100rpx;height: 100rpx;margin: 20rpx;background-color: rebeccapurple}.focus{background-color: red;}

微信小程序页面传递循环列表数据

5、在mypage.js中为点击事件添加响应函数,代码如下:itemtap:funct坡纠课柩ion(e){ console.log(e) var that = this; that.setData({curItem:e.target.dataset.index}) wx.navigateTo({ url: '../logs/logs?item='+e.target.dataset.cont, })}

微信小程序页面传递循环列表数据

7、在logs.js中添加数据接收传递过来的参数,在onload事件中显示数据,代码如下:Page({data: { logs: [], datavar:null,},onLoad: function (options) { console.log(options) this.setData({ datavar:options.item })}})

微信小程序页面传递循环列表数据
猜你喜欢