在平常使用JSON进行跳转传参时都是正常的,但是今天用不知道为什么进行了报错Unexpected end of JSON input,
原因
在网上找到了答案是因为传递的参数中有识别不到的内容,我传递的参数里面包含了富文本,所以没有解析出来
解决办法
先在准备跳转的页面JSON字符化参数(父页面)
issueanswer(item){
let arrar = JSON.stringify(item)
uni.navigateTo({
url:"issueanswer?arr="+encodeURIComponent(arrar)
})
},
然后在子页面的onLoad里面接受参数并解析
onLoad(option) {
this.arr =JSON.parse(decodeURIComponent(option.arr))
},