Page组件
如果是 Page
组件, 调用 getOpenerEventChannel
函数必须在 onLoad
函数里面执行:
Page({
...
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let eventChannel = this.getOpenerEventChannel()
eventChannel.on('editEquipEvent', function (data) {
if (data.equipInfo == undefined) {
return
}
this.setData({
id: data.id,
equipType: data.equipInfo.equipType,
equipName: data.equipInfo.equipName,
trickId1: data.equipInfo.trickId1,
trickId2: data.equipInfo.trickId2,
deltaPropArray: data.equipInfo.deltaPropArray
})
})
},
...
})
Component
如果是 Component
组件, 调用 getOpenerEventChannel
函数必须在 method -> onLoad
函数里面执行:
Component({
...
methods: {
onLoad(options) {
let eventChannel = this.getOpenerEventChannel()
eventChannel.on('editEquipEvent', function (data) {
if (data.equipInfo == undefined) {
return
}
this.setData({
id: data.id,
equipType: data.equipInfo.equipType,
equipName: data.equipInfo.equipName,
trickId1: data.equipInfo.trickId1,
trickId2: data.equipInfo.trickId2,
deltaPropArray: data.equipInfo.deltaPropArray
})
})
},
}
...
})