ホームページ  >  に質問  >  本文

主键中调用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);
        }
      });
    },
  },

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

高洛峰高洛峰2912日前1763

全員に返信(1)返信します

  • 三叔

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

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

    返事
    0
  • キャンセル返事