简体   繁体   English

vue路由器未使用同一对象的新数据更新url

[英]vue router not updating url with new data of same object

i have a vue login form thats returns the errors as a query. 我有一个Vue登录表单,多数民众赞成返回错误作为查询。 after the first error the query object is loaded the the error string, the subsequent once are not even if they show up in the console... 在第一个错误之后,查询对象将加载错误字符串,随后的一次即使它们出现在控制台中也不会出现...

store.js... store.js ...

userLogin({ commit }, { email, password }) {
      firebase
        .auth()
        .signInWithEmailAndPassword(email, password)
        .then(user => {
          commit("setUser", user);
          commit("setIsAuthenticated", true);
          console.log("User: " + user.user.uid + "found")
          router.push("/dashboard");
        })
        .catch((error) => {
          commit("setUser", null);
          commit("setIsAuthenticated", false);
          console.log("Login Error: " + error.message);
          router.go({name: "signin", force: true,  query: {errorMessage: error.message, signinError: true}});
        });
    },

signin script.... 登录脚本...。

    data() {
        return {
          email: "",
          password: "",
          performingRequest: false,
          signinError: false,
          signupSuccessful: false,
          errorMessage: "",
          successMessage: ""
        };
      },
      created() {
        if(this.$route.query.signinError) {
          this.signinError = this.$route.query.signinError;
          this.errorMessage = this.$route.query.errorMessage;
        }
      },
methods: {
    validateStep(scope) {
      this.$validator.validateAll(scope).then(result => {
        if (result) {
          this.performingRequest = true
          this.$store.dispatch("userLogin", {
            email: this.email,
            password: this.password
          })
        }
      });
    }
  }

signin template.... 登录模板...。

<v-alert :value="signinError" type="error" >
          {{errorMessage}}
          </v-alert>
          <v-alert :value="signupSuccessful" type="success" >
          {{successMessage}}
          </v-alert>

I am not sure I fully understand your question...but from a glance, I spotted an issue: This: router.go(); 我不确定我是否完全理解您的问题...但是乍一看,我发现了一个问题: router.go();router.go(); is now: router.push(); 现在是: router.push(); Check this doc out: https://router.vuejs.org/guide/essentials/navigation.html 检查此文档: https : //router.vuejs.org/guide/essentials/navigation.html

Let me know if you need further help. 让我知道您是否需要进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM