实现效果:
点击页面
(1)用自定义属性data-index保存当前点击列表的index,在点击跳转的方法中获取index并且拼接到要跳转的路径后面:
readcd:(e)=> {
let index=e.currentTarget.dataset.index;
wx.navigateTo({
url: '../cd_read/cd_read?index='+index,
})
},
(2) 跳转到详情页,在onLoad中通过参数options获取传过来的index,渲染对应的数据
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
var that = this
let index = options.index;
//当页面加载时请求数据
wx.request({
url: '******************************',
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded',
},