Vue route 退出在登陆还能回到退出时的页面

228 阅读1分钟

退出时加一个查询参数

 ?后边的是查询参数   fullPath比path更完善
 使用encodeURIComponent进行转码
 this.$router.push('/login?return_url=' + encodeURIComponent(this.$route.fullPath))

登录

 this.$route.query.return_url就是退出时页面的哈希路径

 this.$router.push(this.$route.query.return_url || '/')

image.png