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

213 阅读1分钟

image.png

原因

参数中有不识别的字符

解决方案

使用encodeURIComponent编码

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