vue中 this.$router.go(-1) 失效,路由改变了,界面未刷新

2023-12-25 19:23:44

vue中 this.$router.go(-1) 返回上一页 失效

问题

在vue项目中使用this.$router.go(-1)返回上一页时,发现有时候该功能是正常的,有时候,路由改变了,但页面依旧停留在当前界面。

解决方法

使用this.$router.back(),返回上一页。

区别

go(-1):原页面中的内容会丢失

this.$router.go(-1) // 后退+刷新
this.$router.go(0) // 刷新
this.$router.go(1) //前进

back():原页面中的内容会保留

this.$router.back() // 后退
this.$router.back(0) // 刷新
this.$router.back(1) // 前进

文章来源:https://blog.csdn.net/xuelong5201314/article/details/135203072
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。