当前位置: 移动技术网 > IT编程>脚本编程>Ajax > async await 异步调用ajax实例

async await 异步调用ajax实例

2020年07月23日  | 移动技术网IT编程  | 我要评论

async await 异步调用ajax实例:
检测文件数, 当文件数量>x , 则返回错误信息, 异 则 发请求 进行删除操作

    //检查文件数,如果超过x,则 禁止用户操作
    async checkFileMount(_tableSelection) {
      this.filemgtLoading = true;
      let response;
      var params = { list: _tableSelection };
      await checkFileCount(params)
        .then(res => {
          response = res;
        })
        .catch(e => {});
      return response;
    },
    // Delete
    handleDelete() {
      this.checkFileMount(this.tableSelection).then(res => {
        //条数少于 x 可以操作
        if (res.msg === "COUNTPASS") {
          this._handleDelete(this.tableSelection);

          this.filemgtLoading = false;
        } else if (res.msg === "OUTOFCOMPASS") {
          this.filemgtLoading = false;
          this.$message({
            showClose: true,
            message: "file count > x, you can't do this",
            type: "error"
          });
        }
      });
    },

本文地址:https://blog.csdn.net/qq_37167049/article/details/107450624

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网