当前位置: 首页 > Web前端 > vue.js

uni-app页面传参

时间:2023-03-31 14:19:50 vue.js

uni-app跳转页面传递数据跳转起始页uni.navigateTo({//普通跳转参数后面直接拼接(当参数不复杂不多时),例如代码andisModifyurl:`../../add-log/add-log?code=${this.option.code}&isModify=${true}`,//执行成功函数success(res){//监听一个自定义的方法名(sendLogData),将更复杂的数据放入datares.eventChannel.emit('sendLogData',{data:params})}});跳转到结束页面onLoad(option){const_vm=this;consteventChannel=this.getOpenerEventChannel();this.eventChannel=eventChannel;//这里sendLogData是起始页自定义监听方法的名称eventChannel.on('sendLogData',function(res){//传入的数据console.log(res)//注意_vm指向_vm.arr=res.数据;})}