通过url进行参数的传递

1、//跳转到page页面并传一个变量file

showVideo(index) {
let file = this.fastImgLists[index].id;
console.log(file);
uni.navigateTo({
url: `../page/page?file=${file}`
});
},

2、//跳转到page页面并将后台返回的值传递过去

url="跳转页面?参数名="+参数+“&参数名”+参数值

uni.navigateTo({

url: '../page/page?id=' + res.data.id 
+ '&name=' + res.data.name
+ '&deviceLocation=' + res.data.deviceLocation
+ '&pageFlag=' + res.data.pageFlag
+ '&device=' + res.data.device
});

在page页面,进行接收,将值写入相应位置

onLoad(obj) {
console.log(obj);
this.id = obj.id;
this.name = obj.name;
this.deviceLocation = obj.deviceLocation;
this.pageFlag = obj.pageFlag;
this.device = obj.device;
},

猜你喜欢

转载自www.cnblogs.com/webzzc/p/11302913.html