我想在我的登录页面中添加一个忘记密码的页面,但是更新代码后无法跳转到它]]

问题描述 投票:0回答:1

我想将忘记的密码页添加到我的登录页,

但是更新代码后我无法跳转到它。

网站错误消息:

  • [vue-router]路线导航期间未捕获的错误
  • 未捕获(承诺)未定义
  • 超出最大调用堆栈大小
  • 旧代码

router.beforeEach((to, from, next) => {
  const isLogin = localStorage.getItem("token") == "ImLogin";
  var role = localStorage.getItem('roles');
  if (isLogin) {
    if (to.matched.every(item => item.meta.indexOf(role) > -1)) {
      next();
    } else {
      next('/tips');
    }
  } else {
    if (to.path !== "/login") next("/login");
    else next();
  }
});

新代码

<v-btn
  class="font-weight-bold"
  style="color:#FF7D52"
  href
  @click.prevent="forgetPassword"
  text
  >forgetPassword
</v-btn>

forgetPassword() {
      this.$router.push("/forgetPassword");
    },
router.beforeEach((to, from, next) => {
  const isLogin = localStorage.getItem("token") == "ImLogin";
  var role = localStorage.getItem('roles');
  if (isLogin) {
    if (to.matched.every(item => item.meta.indexOf(role) > -1)) {
      next();
    } else {
      next('/tips');
    }
  } else {
    if (to.path === "/forgetPassword") {
      next("/forgetPassword");
    } else {
      if (to.path !== "/login") next("/login");
      else next();
    }
  }
});

我想在登录页面中添加一个忘记密码的页面,但是更新代码后无法跳转到该页面。网站错误消息:[vue-router]路线导航期间未捕获错误未被捕获(...

javascript vue.js vuetify.js
1个回答
0
投票
if (to.path === "/forgetPassword") {
      next("/forgetPassword");
}
© www.soinside.com 2019 - 2024. All rights reserved.