0
点赞
收藏
分享

微信扫一扫

VUE 同一页面路由参数变化,视图不刷新的解决方案

1.监听路由处理

watch: {
$route(to, from) {
// 逻辑
// 重新调用数据接口

}
},

2.beforeRouteUpdate导航守卫 路由更新时触发​

beforeRouteUpdate (to, from, next) {
// 逻辑
this.$route.query.xx = to.params.xx;

next() // 一定要有next

3.只需要在入口文件设置监听事件即可

<div id="app" :key="Key">

</div>

data() {
return {
Key: ''
};
},
watch: {
$route: function(newUrl, oldUrl) {
this.Key = new Date().getTime();
}
}



举报

相关推荐

vue路由判断跳转404页面

0 条评论