1.从其他界面返回
点击提交按钮或者其他按钮,操作完毕,
返回上一个界面的方法:
[detail.vue]:
submit() {
...
window.history.back()
}
2.主界面监听并重新获取数据从而刷新
[mainList.vue]:
watch: {
$Route(to, from ) {
const fname = from.name
const tname = to.name
console.log('界面切换,从:', from.name, '到当前界面:', to.name)
this.query()
}
},
3.可以在其他界面设置meta变量
从而确定返回主界面后,是否刷新主届面。
[common/router/modules/routes.js]:
const routes = [
{
path: "/pages/detail",
name: "detal",
meta: {
title: "详情界面",
isRefresh: true,
},
},
...
]
4.在主界面获取该变量做判断
[mainList.vue]:
watch: {
$Route(to, from ) {
const fname = from.name
const tname = to.name
console.log('界面切换,从:', from.name, '到当前界面:', to.name)
if (true = from.name.isRefresh) {
this.query()
}
}
},