Home  >  Q&A  >  body text

主键中调用vue-router的push方法跳转页面无反应?

代码如下

  methods: {
    ...mapActions(['doLogin']),
    login() {
      this.doLogin({ username: this.username, password: this.password }).then((loginInfo) => {
        if (loginInfo.error === 200) {
          console.log('登录成功');
          if (this.$route.query.redirect !== undefined) {
            this.$router.push(this.$route.query.redirect);
          } else {
            this.$router.push('/index');
          }
        } else {
          console.log(loginInfo.msg);
        }
      });
    },
  },

登录成功有打出来,但是页面静止没有跳转,也没有报错

高洛峰高洛峰2817 days ago1680

reply all(1)I'll reply

  • 三叔

    三叔2016-10-29 09:37:31

    全局的router对象,router.push() 而不是当前路由信息对象 $router

    reply
    0
  • Cancelreply