1.index.wxml中添加测试用的view
<view bindtap='TesetPage'>
进入测试页面
</view>
2.index.js中添加绑定的方法,参数在这里传递,方法与url传参一样
TesetPage(){
wx.redirectTo({
url: '../test/test?id=11&act=delid',
})
}
3.test.js data中添加需要的设置的变量,并在在生命周期的onLoad方法中添加设置接受传参并设置到变量的代码
data: {
articaleId : null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
this.setData({
articaleId:options.id
})
},
4.在text.wxml中使用test.js中的变量
<!--pages/test/test.wxml-->
<text>pages/test/test.wxml</text>
<view>ID:{{articaleId}}</view>
经过测试可以正常在test页面中显示出来