美文网首页
element-ui中el-popconfirm点击无效没有弹窗

element-ui中el-popconfirm点击无效没有弹窗

作者: 人生就是不断学习 | 来源:发表于2021-11-17 17:30 被阅读0次

    查了许久源码,发现是冒泡问题

    下面附上解决方案:

    修改前:

      <el-popconfirm title="删除?" @confirm="popConfirm"  @cancel="popCancel">
    <el-button type="danger" size="mini" slot="reference" icon="el-icon-delete">删除</el-button>
    
      </el-popconfirm>
    
    

    修改后:

    
    <span @click="delBtn">
                <el-popconfirm title="删除?" @confirm="popConfirm"  @cancel="popCancel">
                  <el-button
                    type="danger"
                    size="mini"
                    slot="reference"
                    icon="el-icon-delete"
                    >删除</el-button>
                </el-popconfirm>
          </span>
    
    methods: {
        popConfirm(){
          console.log('确认')
        },
        popCancel(){
          console.log('取消')
        },
        delBtn(e){
         e.stopPropagation();
        },
    }
    

    相关文章

      网友评论

          本文标题:element-ui中el-popconfirm点击无效没有弹窗

          本文链接:https://www.haomeiwen.com/subject/brzltrtx.html