两个tab切换对应2个组件,一个组件监听onReachBottomOne,一个是onReachBottom,下面这样写是否可以呢,不销毁会执行好几次“加载下一页”
// 主页面
onReachBottom(){
if(this.tabIndex == 0){
uni.$emit('onReachBottomOne');
}else{
uni.$emit('onReachBottom');
}
},
// 子组件1
created(){
uni.$on('onReachBottomOne', () => {
console.log('加载下一页');
});
},
beforeDestroy(){
uni.$off('onReachBottomOne');
},
// 子组件2
created(){
uni.$on('onReachBottom', () => {
console.log('加载下一页');
});
},
beforeDestroy(){
uni.$off('onReachBottom');
},