微信小程序路由传参(多参数、对象)

4,659 阅读1分钟

1:普通传参

直接在url后面跟上就行,多个参数使用&隔开

wx.navigateTo({
    url:"www.baidu.com?id_1=" + 1 + "&id_2=" + 2
})

2:对象参数

对于要传一个对象

const id_1 = JSON.stringify(parameter)
const id_2 = JSON.stringify(paramter)
wx.navigateTo({
    url: '../details/details?id_1=' + id_1 + '&id_2=' + id_2,
})
onLoad:function(options){
    const id_1 =  JSON.parse(options.id_1)
}