收藏
回答

页面间以URL参数传值时值被截断

问题模块
API和组件

当我使用

wx.navigateTo({

      url: xxx?key1=value1,

    })

传值时,如果参数(value1)值长度比较长时,会出现参数被截断的情况。导致在跳转到的页面的onload函数中,无法正确json parse。

例如:

    跳转之前:

    {"status":4,"comment":"4","tags":[{"colum_set":1,"id":1,"name":"搞笑"},{"colum_set":1,"id":62,"name":"内涵"},{"colum_set":1,"id":55163,"name":"主版块"},{"colum_set":1,"id":68,"name":"漫画"},{"colum_set":1,"id":4670,"name":"涨姿势"}],"bookmark":"5","text":"别光看球,你知道NBA到底咋回事么?","image":{"medium":[],"big":["http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_1.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_1.jpg"],"download_url":["http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_d.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_d.jpg","http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d.jpg"],"height":22433,"width":750,"small":[],"thumbnail_small":["http://wimg.spriteapp.cn/crop/150x150/ugc/2017/06/13/593f71abf2a1d.jpg","http://dimg.spriteapp.cn/crop/150x150/ugc/2017/06/13/593f71abf2a1d.jpg"]},"up":"94","share_url":"http://a.f.budejie.com/share/25359529.html?wx.qq.com","down":13,"forward":6,"u":{"header":["http://tva4.sinaimg.cn/crop.0.0.996.996.50/e7f9e94djw8f6ursgyso3j20ro0rp0wy.jpg","http://tva4.sinaimg.cn/crop.0.0.996.996.50/e7f9e94djw8f6ursgyso3j20ro0rp0wy.jpg"],"uid":"19531820","is_vip":false,"is_v":false,"room_url":"","room_name":"Ms","room_role":"帮主","room_icon":"http://wimg.spriteapp.cn/ugc/2016/1101/gang_level_5.png","name":"臭宝蛋蛋 [Ms]"},"passtime":"2017-06-14 15:24:01","type":"image","id":"25359529"}

    跳转接收到的为:

    {"status":4,"comment":"4","tags":[{"colum_set":1,"id":1,"name":"搞笑"},{"colum_set":1,"id":62,"name":"内涵"},{"colum_set":1,"id":55163,"name":"主版块"},{"colum_set":1,"id":68,"name":"漫画"},{"colum_set":1,"id":4670,"name":"涨姿势"}],"bookmark":"5","text":"别光看球,你知道NBA到底咋回事么?","image":{"medium":[],"big":["http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_1.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_1.jpg"],"download_url":["http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_d.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d_d.jpg","http://wimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d.jpg","http://dimg.spriteapp.cn/ugc/2017/06/13/593f71abf2a1d.jpg"],"height":22433,"width":750,"small":[],"thumbnail_small":["http://wimg.spriteapp.cn/crop/150x150/ugc/2017/06/13/593f71abf2a1d.jpg","http://dimg.spriteapp.cn/crop/150x150/ugc/2017/06/13/593f71abf2a1d.jpg"]},"up":"94","share_url":"http://a.f.budejie.com/share/25359529.html

被截掉很长一段数据,无语。。。。。

最后一次编辑于  2017-06-14  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

3 个回答

  • maq
    maq
    2017-06-14

    这么长的字符串,最好还是别用页面参数来传吧……


    如果真的有这么多数据需要传,不妨生成一个随机的 key,然后把这些数据用 key 保存在 app 里,把 key 作为参数传过去。

    2017-06-14
    赞同
    回复
  • SHINING诗永
    SHINING诗永
    2017-06-14

    非要这样传数据吗⊙﹏⊙‖∣

    2017-06-14
    赞同
    回复
  • 自由马@西瓜科技
    自由马@西瓜科技
    2017-06-14

    真的不太想把这个数据作为全局变量存下来,如果实在没办法,也只好这样了

    2017-06-14
    赞同
    回复