页面效果:
实现代码:
handleAppove() {
this.$modal.loading("正在审批,请稍候...");//开启加载中
this.$refs['approvForm'].validate((valid) => {
if (valid) {
approveBatchNo(this.approvForm).then((res) => {//请求接口
if (res.code == 200) {
if(res.data.failNum!=0){
this.$modal.msgError(`审批失败${res.data.failNum}条数据`)
}
if(res.data.sucNum!=0){
this.$modal.msgSuccess(`审批成功${res.data.sucNum}条数据`)
}
this.approvDialog = false
this.getList()
this.$modal.closeLoading() //响应成功关闭加载中
}else{
this.$modal.closeLoading() //响应失败关闭加载中
}
})
}
})
},
如果要改变加载中字体与背景可以这样写:
handleSubmit() {
let loading = this.$loading({
lock: true, //lock的修改符--默认是false
text: "加载中,请稍候...", //加载提示文字
background: "rgba(0,0,0,0.8)", //遮罩层颜色
spinner: "el-icon-loading", //自定义加载图标类名
});
const data = this.arr;
getList(data).then((response) => {
if (response.code == 200) {
loading.close(); //响应成功关闭加载
this.$message({
message: "提交成功",
type: "success",
});
this.cancel();
}
});
}