$confirm弹框按钮区分,以及加载样式
取消,关闭按钮区分
this.$confirm('提示?', {
confirmButtonText: '确定',
showClose: false,
cancelButtonText: '拒绝',
type: 'warning',
closeOnPressEscape:false,//按下 ESC 键关闭弹窗
closeOnClickModal:false,//点击遮罩关闭弹窗
distinguishCancelAndClose:true,//区分取消与关闭
})
//确定操作
} catch (e) {
if (e == 'cancel') {
//取消操作
}
if(e == 'close') {
//关闭操作
}
}
添加加载样式
this.$confirm(`xxxxxxxxxxxxxxxxxxxxx`, '提示', {
beforeClose: async(action, instance, close) => {
//isProcessing控制重复执行
if (this.isProcessing) return
if (action == 'confirm') {
this.isProcessing = true
//加载开始
instance.confirmButtonLoading = true
// 模拟异步操作,例如 API 调用
setTimeout(() => {
instance.confirmButtonLoading = false;
this.isProcessing = false; // 重置标志位
close(); // 关闭对话框
// 这里可以执行实际的确认操作逻辑
console.log('Confirmed!');
}, 2000);
} else {
close()
}
}
})