父页面 调用 uni.navigateTo
注意success中res对象 有个eventChannel
showCheckList() {
let _vm = this;
uni.navigateTo({
url: '/pages/component/trial-manufacture/check-list',
success: function(res) {
res.eventChannel.emit('login', {
examineList: _vm.trialProduceExamineList,
station: _vm.station,
stationList: _vm.userStationList
})
}
})
}
子页面接收参数, onLoad时调用this.getOpenerEventChannel
onUnload时记得解除监听
data() {
return {
eventChannel: null,
}
},
onLoad(options){
const eventChannel = this.getOpenerEventChannel();
this.eventChannel = eventChannel;
let _vm = this;
eventChannel.on('login', function(params) {
let {examineList, station, stationList} = params;
_vm.examineList = examineList;
_vm.station = station;
_vm.stationList = stationList;
})
},
onUnload() {
this.eventChannel.off('login');
},
参考文档:
https://uniapp.dcloud.io/api/router?id=event-channel