小程序携带参数(单个或多个)跳转页面(实例)
时间:2019-03-29 12:53:04
收藏:0
阅读:243
小程序html部分
data为传递至js的变量 name和id为变量名
<button class="an" data-name="钧一" data-id="888" bindtap="tz">点我跳转</button>
js部分
e是接收到的参数,打印e.currentTarget.dataset即可看见你所传递的变量
tz: function (e) { console.log(e) wx.navigateTo({ url: "../jy/jy?id= " + e.currentTarget.dataset.id + "&name=" + e.currentTarget.dataset.name,//传递多个变量
//url: "../jy/jy?id= " + e.currentTarget.dataset.id//传递单个变量
//url: "../jy/jy?id=333"//直接传递数据
})
}
jy页面
在js里找到
onLoad: function (options) {
//options则里就是你传递过来的变量
console.log(options)
}
原文:https://www.cnblogs.com/junyi-bk/p/10620100.html
评论(0)