//问题就是在于this的指向,解决办法是使用变量保存$on,其次在为data中的值赋值
//A页面
onShow() {
//页面通讯接收
const on = uni.$on('updateRoomList', function (data) {
this.newRoomName = data.roomName
})
this.newRoomName = on.newRoomName
const ind = this.getSortRoomList.findIndex((x) => x.n === this.newRoomName)
if (ind > -1) {
this.currentRoomList.push(this.getSortRoomList[ind])
}
},
//移除监听
onUnload() {
uni.$off('updateRoomList')
},
//B页面:另一个页面$emit
uni.$emit('updateRoomList', { roomName: _name })
uni.navigateBack()