微信小程序报错Unexpected end of JSON input


小程序报错Unexpected end of JSON input如下图

1

原因

参数中有不识别的字符

解决方案

使用encodeURIComponent编码

  //父页面
  let item = JSON.stringify(json)
  wx.navigateTo({
      url: '/xxx?item=' + encodeURIComponent(item)
  })
  //子页面
  onLoad: function(options){
      let item = JSON.parse(decodeURIComponent(optines.item))
  }
     


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM