取消 ElMessageBox.confirm 确定按钮的回车(enter)事件

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(() => { })
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容