handleLogin() {
      this.$http.post("login", this.formLabelAlign).then(res => {
        const {
          data,
          meta: { msg, status }
        } = res.data;
        if (status === 200) {
          this.$message({
            showClose: true,
            message: msg,
            type: "success"
          });
          this.$router.push({ name: "home" });
        } else {
          this.$message({
            showClose: true,
            message: msg,
            type: "error"
          });
        }
      });
    }

使用await的方式
简记在函数的前面使用async
在请求时,使用await。然后用一个变量进行接收哈。

     async handleLogin() {
      const res = await this.$http.post("login", this.formLabelAlign);
      const {
        data,
        meta: { msg, status }
      } = res.data;
      if (status === 200) {
        this.$message({
          showClose: true,
          message: msg,
          type: "success"
        });
        this.$router.push({ name: "home" });
      } else {
        this.$message({
          showClose: true,
          message: msg,
          type: "error"
        });
      }
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-09-30
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-07-23
  • 2022-12-23
相关资源
相似解决方案