发布时间:2021-04-21 12:57:24编辑:admin阅读(4985)
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标签展开行
 51251
 50685
 41286
 38107
 32571
 29471
 28333
 23197
 23161
 21489
 1564°
 2284°
 1890°
 1829°
 2143°
 1876°
 2565°
 4298°
 4150°
 2959°