发布时间:2021-04-21 12:57:24编辑:admin阅读(4975)
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标签展开行
51228
50657
41267
38080
32549
29452
28313
23173
23134
21466
1532°
2241°
1867°
1806°
2104°
1856°
2540°
4264°
4116°
2938°