发布时间:2021-04-21 12:57:24编辑:admin阅读(5566)
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标签展开行
53219
40108
34478
30222
25131
24924
23323
16836
14928
14443
807°
740°
807°
821°
871°
995°
975°
982°
1084°
999°