this.$confirm in vue, confirm and cancel to execute different logic processing

Effect picture:
insert image description here
[OK] button executes logic A, [Cancel] button executes logic B. The [x] button closes the confirm, and the cancel button executes different logic codes as follows:

this.$confirm("是否确定删除选中的数据?", "提示", {
    
    
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    distinguishCancelAndClose: true,    // 重要,设置为true才会把右上角X和取消区分开来
    closeOnClickModal: false
}).then(function () {
    
    
    // TODO 确认通过执行逻辑
 
}).catch(function (e) {
    
    
    if (e == 'cancel') {
    
    
        // TODO 确认不通过执行逻辑
         
    } else if(e == 'close') {
    
    
        // TODO 右上角X的执行逻辑
 
    }
})



Guess you like

Origin blog.csdn.net/weixin_42342065/article/details/126628282