微信小程序点击携带参数报错Unexpected end of JSON input;at “xxx” page lifeCycleMethod
解决方法
//页面跳转传递参数 使用encodeURIComponent
wx.navigateTo({
url: '../../release/releaseOffer/index?type=asset&flag=1"eInfo=' + encodeURIComponent(quoteInfo)
})
//子页面接收数据的时候 使用decodeURIComponent这个方法
let optionsData = decodeURIComponent(options.quoteInfo)
that.setData({
quoteInfo: JSON.parse(optionsData),
})
主要是url传递参数的时候,里面有特殊的字符,导致url解析失败,所以必须在传参的时候需要对参数就行 encodeURIComponent(data)