ant design vue table组件中popconfirm按钮,阻止事件冒泡到表格行事件

问题描述:

目前做的项目,在vue ant design vue table组件中,对按钮应用popconfirm弹窗,此前已经对该table组件应用了:customRow="rowclick"属性,即注册了行级事件,在点击表格中的按钮时同时出发了按钮事件以及行事件,导致行为冲突。

如下图所示。在点击表格中移除按钮时,希望弹窗展示popcoirm内容,但是同时触发了行事件,弹出了其他页面。

解决办法:在按钮上绑定click.stop=""事件,事件的内容是空,使该按钮在点击的时候,不会触发行事件,单不会阻止popconfirm的弹出。

之前直接用click.stop,后面没有赋值空内容,不好用,然后后面加个赋值为空就可以了,今天发现直接用click.stop又可以了~~~。

              <template slot="operation" slot-scope="text, record">
                <a-popconfirm placement="top" ok-text="确定" cancel-text="取消" @confirm="removePlanCase([record.id])">
                  <template slot="title">
                    <p>确认移除该用例么?</p>
                  </template>
                  <a @click.stop="">移除</a>
                </a-popconfirm>
              </template>

  

原文地址:https://www.cnblogs.com/xiaxiaoxu/p/14923792.html