vue 监听 路由 meta的变化

------------恢复内容开始------------

------------恢复内容开始------------

1.配置路由

{
path: '/hellow',
name:"hellow",
component: hellow,
meta:{title:"hellow"}

}

2,在mount里面赋值

mounted(){
   this.title=this.$route.matched;
},

3,由于在页面上刷新才可以显示,所一需要watch监听 

watch: {
'$route.matched': function (newVal, oldVal) {
this.title=this.$route.matched;
}
},

3.0的监听watch(()=>root.$route,(to,from)=>{

state.title=to.matched;

})

------------恢复内容结束------------

------------恢复内容结束------------

原文地址:https://www.cnblogs.com/xzhce/p/13321929.html