首页要确定是否是路由跳转,不局限语父子跳转
子页面返回写法
this.$router.push({
path: "/",//上级页面的路径
query: { key: this.$route.query.id }//传到父级的值。
});
//父页面
//在watch中监听值的变化
watch: {
$route(to, from) {
//监听路由是否变化
if (to.query.key != from.query.key) {
this.key = to.query.key;
this.init(); //重新加载数据
}
}
},