let pages = getCurrentPages();
// 上一个页面实例
let prevPage = pages[pages.length - 2];
// 刷新上一页数据
// #ifdef APP-PLUS
prevPage.$vm.pullRef()
// #endif
// #ifndef APP-PLUS
prevPage.pullRef()
// #endif
//或者使用监听
// 在页面的onLoad中添加事件监听
onLoad() {
uni.$on('refreshTabBarPage', this.refreshTabBar);
},
// 定义事件处理函数
methods: {
refreshTabBar() {
// 这里添加你的刷新逻辑,比如重新加载数据
this.loadData();
},
loadData() {
// 假设这是你加载数据的方法
console.log('加载数据');
}
},
// 在页面销毁时移除事件监听,避免内存泄露
onUnload() {
uni.$off('refreshTabBarPage', this.refreshTabBar);
}
// 在其他页面发送事件通知页面进行刷新
uni.$emit('refreshTabBarPage');
01-14
1145
02-17
2205
11-01
2219
07-28