在vuex中无法直接使用this.$rouer
和this.$route
会报错:
// 退出时将当前页路由作为参数记录进链接,方便下一次进入跳转
this.$router.push(`/login?redirect=${this.route.fullPath}`);
import router from "@/router"
引入项目中路由表文件暴露的 router
不要直接引入import Router from "vue-router"
会获取不到值
正确用法:
import router from "@/router"
// 退出时将当前页路由作为参数记录进链接,方便下一次进入跳转
router.push(`/login?redirect=${router.currentRoute.fullPath}`);
网友评论