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;

})

 

------------恢復內容結束------------


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM