小程序页面跳转url携带参数,参数能否为{{"a":1,"b":2}}这种对象类型?
<navigator url="..etwork/pull-refresh/pull-refresh?detail={{detail}}" open-type="navigate"class="uploader-text">
detail:{ "a":'路由传递的参数',"b":2, },
小程序页面跳转url携带参数,参数能否为{{"a":1,"b":2}}这种对象类型?The redirect URL of the Mini Program page carries parameters. Can the parameters be {{"a":1,"b":2}} this type of object?
小程序页面跳转url携带参数,参数能否为{{"a":1,"b":2}}这种对象类型?小程序页面跳转url携带参数,参数能否为{{"a":1,"b":2}}这种对象类型?
<navigator url="..etwork/pull-refresh/pull-refresh?detail={{detail}}" open-type="navigate"class="uploader-text">
detail:{ "a":'路由传递的参数',"b":2, },
Applet page Jump URL carries parameters. Can the parameters be {{"a": 1, "B": 2}? < navigator url =. / network / pull refresh / pull refresh? Detail = {detail} "open type =" Navigator "class =" uploader text "> detail: {" a ": 'parameters of routing'," B ": 2,},
回答:
1.先用JSON.stringify() 转成字符串
2.传输前用 encodeURIComponent 进行编码
3.接收时用 decodeURIComponent 进行解码
4.用JSON.parse() 转成对象
====================
用wx.setStorageSync和wx.getStorageSync不香吗?
navigator 组件恐怕不行,参考一下写法:
wx.navigateTo({ url: "..etwork/pull-refresh/pull-refresh?detail=" + encodeURIComponent(JSON.stringify(this.data.detail))})
可以, 先JSON.stringify(detail)把对象转成字符串, 拿到字符串后通过JSON.parse()解析回来