小程序報錯Unexpected end of JSON input如下圖
原因
參數中有不識別的字符
解決方案
使用encodeURIComponent編碼
//父頁面
let item = JSON.stringify(json)
wx.navigateTo({
url: '/xxx?item=' + encodeURIComponent(item)
})
//子頁面
onLoad: function(options){
let item = JSON.parse(decodeURIComponent(optines.item))
}