element confirm确认框阻止键盘回车事件

使用beforeClose(){}这个函数

 this.$confirm("出库电池是否选择租赁站点?", "提示", {
        confirmButtonText: "是",
        cancelButtonText: "否",
        type: "warning",
        closeOnClickModal:false,
        //阻止键盘点击回车事件
        beforeClose(action,instance,done){  
             // console.log(action,instance)
             if(action=="confirm"){
               instance.$refs['confirm'].$el.onclick=function(e){
                 e=e||window.event
                 console.log(e.detail)
                 if(e.detail!=0){
                     done()
                 }
               }
             }else{
               done()
             }
         }
        }).then(()=>{})
        .catch(() => {})

你可能感兴趣的:(element confirm确认框阻止键盘回车事件)