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