方案一
通过监听器实现
page1
javascript
uni.$on("refresh", function(data) {
if(data.page === "page2") {
this.reload()
}
})
page2
javascript
methods: {
handleBack() {
uni.$emit("refresh", {
page: "page2"
})
uni.navigateBack()
}
}
方案二
通过页面实例实现
page1
javascript
methods: {
reload() {
}
}
page2
javascript
methods: {
handleBack() {
uni.navigateBack({
success() {
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
prevPage.reload()
}
})
}
}
参考
https://uniapp.dcloud.net.cn/api/window/communication.html
https://uniapp.dcloud.net.cn/api/window/window.html