uniapp 页面传值的方法(待更新)

344 阅读1分钟

第一种:url传值

tempData是一个数组对象 JSON.stringify 转换

//encodeURIComponent()加密
//tempData =encodeURIComponent( JSON.stringify(tempData)) 
tempData = JSON.stringify(tempData)
uni.navigateTo({
    url: `../listData/listData?item=${tempData}`
})

页面接收 JSON.parse 转换

onLoad(options) {
    //decodeURIComponent()解析
    //console.log(JSON.parse(decodeURIComponent(options.item)));
    console.log(JSON.parse(options.item));
}