Secondary page code:
uni.navigateBack({
delta: 1,
success() {
const pages = getCurrentPages();
const targetPage = pages[0];
targetPage.$vm.addJournalState=true
}
})
Some bloggers get the information on the previous page through this way: var targetPage = pages[pages.length - 2], I get it like this and it shows undefined, you can print the ages, look at the content, and then choose by yourself
annotation:
getCurrentPages()
method to get the current page stack
$vm
Refers to the Vue component instance
First level page code:
onShow() {
setTimeout(() => {
if (this.addJournalState) {
// 重新获取数据
this.upJournal()
this.addJournalState = false
}
}, 100)
}
Every time the page is switched, it will be judged. If the specified secondary page returns, the status will be set to true, and the code will be executed to retrieve the data. Others will not
annotation:
The reason for using setTimeout is to confirm that the state of the first-level page addJournalState has been modified