退出登录 返回登录页 时带上当前页面的fullPath
// .vue文件中写法
this.$router.push('/login?return_url='+ encodeURIComponent(this.$route.fullPath))
// .js文件中写法
router.push('/login?return_url='+ encodeURIComponent(router.currentRoute.fullPath))
// encodeURIComponent对路径进行转码, 防止路径参数丢失
return_url 只是用来接收退出时带回的数据 名字可以随便起(得合法) 回到登录页后可以在vue调试工具 $route / query 中找到 return_url: "带回来的路径数据"
从登录页登录
// 有路径登录就调回原路径 没有 跳主页
const return_url = this.$route.query.return_url || '/'
this.$router.push(return_url)