uniapp 开发这个 Error in onLoad hook: “SyntaxError: Unexpected end of JSON input“

这个其实是由于JSON.parse无法识别某些url中的特殊字符比如&等特殊符号造成的
解决办法:

uni.navigateTo({
    url: '../confirmOrder/confirmOrder?data='+encodeURIComponent(JSON.stringify(data))// 传参
});

接受页面

onLoad(option) {
	// 接收数据
	let str = decodeURIComponent(option.data)
	this.datainfo = JSON.parse(str)
}

主要就是使用encodeURIComponent 和 decodeURIComponent, 如有问题可以留言或者私聊

猜你喜欢

转载自blog.csdn.net/weixin_42132841/article/details/125659293