欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 游戏 > element-plus中Popconfirm气泡确认框组件的使用

element-plus中Popconfirm气泡确认框组件的使用

2025/3/20 21:29:49 来源:https://blog.csdn.net/qq_63981644/article/details/146312173  浏览:    关键词:element-plus中Popconfirm气泡确认框组件的使用

1、基本使用

从element-plus官网复制代码:

<template><el-popconfirm title="Are you sure to delete this?"><template #reference><el-button>Delete</el-button></template></el-popconfirm>
</template>

运行效果:

实现原理:在el-popconfirm组件(气泡确认框组件)内,自定义#reference插槽,然后在插槽中放一个el-buttton按钮,这样就能实现一点击按钮,就弹出气泡确认框的效果。

(具体是如何弹出的,归功于#reference插槽,这个插槽是element-plus官方定义的,我们知道如何使用即可。)

2、修改气泡确认框中,标题名称和两个按钮的名称

期望效果:

代码: 

<el-popconfirm title="您的审核意见" confirm-button-text="通过" cancel-button-text="不通过"><template #reference><el-button type="success" v-if="row.dailyState == 2" @click="review(row)">审核</el-button></template>
</el-popconfirm>

 解读:

①title="您的审核意见"表示修改气泡确认框的标题。

②confirm-button-text="通过"表示将确认按钮修改为“通过”

③cancel-button-text="不通过"表示将取消按钮修改为“不通过”

3、气泡确认框的两个事件:确认事件、取消事件

@confirm是确认事件,@cancel是取消事件。

举例:

<el-popconfirm title="您的审核意见" confirm-button-text="通过" cancel-button-text="不通过" @confirm="passInvoice(row)" @cancel="refuseInvoice(row)"><template #reference><el-button type="success" v-if="row.dailyState == 2">审核</el-button></template>
</el-popconfirm>
//点击气泡确认框的“通过”按钮,触发事件passInvoice()
const passInvoice = () => {alert("通过");
}//点击气泡确认框的“不通过”按钮,触发事件refuseInvoice()
const refuseInvoice = () => {alert("不通过");}

运行效果:

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词