发布时间:2021-04-21 12:57:24编辑:admin阅读(5619)
vue-router跳转一般是这么写:
toCurrentPage: function(thisId){
this.$router.push({path:'/test ', query: { id: thisId, option: ""}});
}但是当遇到,需要跳转同页面不同query的情况,上面的方法不起作用。当然了,从性能来说,理论上这种情况最佳的解决方案,是把需要刷新的包裹成一个init function,跳转的方法,传参再次调用init方法。balabalabala……不在赘述。
但是另一些情况,基本页面所有组件都需要刷新,再次加载对开销影响不大,需要history.back以保证操作逻辑顺畅……我们只要跳转加载如此而已,那么其实也很简单,只需在上述方法基础上加上:
watch: { '$route' (to, from) {
this.$router.go(0);
}
},监视router变化,刷新页面,效果就正常了!
本文参考链接:
https://blog.csdn.net/wulala_orz/article/details/78928524
上一篇: ElementUI table标签展开行
53429
40270
34670
30416
25306
25097
23500
18010
15089
14605
1034°
968°
1031°
1041°
1079°
1231°
1203°
1184°
1277°
1210°