uniapp路由传递数组对象报错Unexpected end of JSON input

原因

在网上找到了答案是因为传递的参数中有识别不到的内容,我传递的参数里面包含了富文本,所以没有解析出来

解决办法

A页面

if(id && id !== 0) {
    
    
	let items = encodeURIComponent(JSON.stringify(this.videoList));
	uni.navigateTo({
    
    
		url:"/pages/classroom/info?id="+id + '&videoList=' + items
	})
}

B页面

onLoad(options) {
    
    
	this.getVideoInfo(options.id)
	if(options.videoList) {
    
    
		this.videoList = JSON.parse(decodeURIComponent(options.videoList))
		console.log(this.videoList);
	}
},

最主要的是encodeURIComponent和decodeURIComponent

猜你喜欢

转载自blog.csdn.net/weixin_46319117/article/details/125821602