小程序页面跳转url携带参数,参数能否为{{"a":1,"b":2}}这种对象类型?

小程序 文章 2021-03-31 17:02 51 0 全屏看文

小程序页面跳转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,},

回答:

微盟:

可以, 先JSON.stringify(detail)把对象转成字符串, 拿到字符串后通过JSON.parse()解析回来

微盟:对象中的值为undefined、function、symbol 时会在转换过程中被忽略
11110111001011110111001110111:

1.先用JSON.stringify() 转成字符串

2.传输前用 encodeURIComponent 进行编码

3.接收时用 decodeURIComponent 进行解码

4.用JSON.parse() 转成对象

====================

用wx.setStorageSync和wx.getStorageSync不香吗?

brave:

navigator 组件恐怕不行,参考一下写法:

wx.navigateTo({  url: "..etwork/pull-refresh/pull-refresh?detail=" + encodeURIComponent(JSON.stringify(this.data.detail))})

-EOF-