取消 ElMessageBox.confirm 确定按钮的回车(

2022-12-06  本文已影响0人  _朽木

element-ui

参考文章 关于ElementUI中MessageBox弹框的取消键盘触发事件(enter,esc)关闭弹窗(执行事件)的解决方法 - 乔的大明 - 博客园 (cnblogs.com)

element-plus

 ElMessageBox.confirm('确认要删除该信息吗?', '警告', {
        type: 'info',
        cancelButtonText: '取消',
        confirmButtonText: '确认',
        beforeClose: (action, instance, done) =>  {
            if (action === 'confirm') {
                instance.onclick = function() {
                    let type = window.event.type
                    if (type !== 'keydown') {
                        done()
                    }
                }()
            } else {
                done()
            }
        }
    }).then(() => {
          ElMessage.success('删除成功')
    }).catch(() => { })
上一篇 下一篇

猜你喜欢

热点阅读