uni-app
跳转页面传输数据
- 跳转起始页面
uni.navigateTo({
//普通跳转传参直接在后面拼接(参数不复杂不多的情况下),例如 code 和 isModify
url: `../../add-log/add-log?code=${this.option.code}&isModify=${true}`,
//跳转成功后执行 success 函数
success(res) {
//监听一个自定义方法名(sendLogData), data 里面放较复杂的数据
res.eventChannel.emit('sendLogData', { data:params})
}
});
- 跳转结束页面
onLoad(option){
const _vm = this;
const eventChannel = this.getOpenerEventChannel();
this.eventChannel = eventChannel;
//这里的 sendLogData 是起始页面自定义的监听方法的名称
eventChannel.on('sendLogData', function(res) {
//传过来的数据
console.log(res)
//注意这里 _vm 的指向
_vm.arr = res.data;
})
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。