const pages = getCurrentPages(); //獲取頁面棧
const beforePage = pages[pages.length - 2]; //前一個頁面
beforePage.data.xxxxx();
beforePage.$vm.getList(); // 觸發父頁面中的方法 可用
發現修改數據界面沒更新,改用uni自帶的通訊方法了。
任意地方
uni.$emit('update',{msg:'頁面更新'})
onLoad
uni.$on('update',function(data){
console.log('監聽到事件來自 update ,攜帶參數 msg 為:' + data.msg);
})
onUnload
uni.$off("update");