wx.navigateTo({
url: 'test?id=1',
events: {
acceptDataFromOpenedPage: function(data) {
console.log(data)
},
someEvent: function(data) {
console.log(data)
}
...
},
success: function(res) {
res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
}
})
Page({
onLoad: function(option){
console.log(option.query)
const eventChannel = this.getOpenerEventChannel()
eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});
eventChannel.emit('someEvent', {data: 'test'});
eventChannel.on('acceptDataFromOpenerPage', function(data) {
console.log(data)
})
}
})
eventChannel.on('acceptDataFromOpenerPage', function(data) {
console.log(data)
})
这里应该是on(‘acceptDataFromOpenedPage’)吧