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
如对本文有疑问, 点击进行留言回复!!
荐 http中status状态为canceled牵扯出的ajax一些问题
网友评论