uniapp中不同页面间的传参
作者:互联网
1.问号传参(当传参个数较少时适用)
godetail(){ uni.navigateTo({ url:"../detail/detail?id=1" }) },
detail页面接收:
onl oad(val) { console.log(val) //{id:1} }
2.传递多个参数时适用
传递方:
godetail() { let userinfo = { name: "王一博", phone: "123456" } let str = JSON.stringify(userinfo) uni.navigateTo({ url: `/pages/detail/detail?options=${encodeURIComponent(str)}` }) },
接收方:
onLoad(val) { let data= JSON.parse(decodeURIComponent(val.options)) console.log(data) }
标签:传参,uniapp,console,val,detail,let,id,页面 来源: https://www.cnblogs.com/-123456/p/16450805.html