vue 跳转当前页面不刷新问题解决办法

115 阅读1分钟

1、在入口文件处

<router-view :key='$route.fullPath'></router-view>

2、watch 监听路由


watch: { 

// 方法1 
'$route' (to, from) { //监听路由是否变化 
    if(this.$route.params.articleId){ // 判断条件1 判断传递值的变化
     //获取文章数据 
    } 
} 
`

//方法2 
'$route'(to, from) { 
    if (to.path == "/page") { // 判断条件2 监听路由名 监听你从什么路由跳转过来的
      this.message = this.$route.query.msg 
    } 
}
`