有时在遇到需要跳转子路由时让当前父路由隐藏,子路由显示可使用
watch: {
// 监听地址栏改变
// to 可获取到哪去的地址
// from 可获取到从哪来的地址
$route(to, from) {
if (to.fullPath.includes("search")) {
this.flag = true;
} else {
this.flag = false;
}
}
},