vue3.0 ElementPlus 中文版入门教程 ElementPlus Popconfirm 气泡确认框

2024-02-25 开发教程 vue3.0 ElementPlus 中文版入门教程 匿名 6

Popconfirm 气泡确认框

点击元素,弹出气泡确认框。

基础用法

Popconfirm 的属性与 Popover 很类似,因此对于重复属性,请参考 Popover 的文档,在此文档中不做详尽解释。

在 Popconfirm 中,只有 title 属性可用,content 属性不会被展示。

<template>
<el-popconfirm title="这是一段内容确定删除吗?">
<template #reference>
<el-button>删除</el-button>
</template>
</el-popconfirm>
</template>

自定义

可以在 Popconfirm 中自定义内容。

<template>
<el-popconfirm
confirmButtonText="好的"
cancelButtonText="不用了"
icon="el-icon-info"
iconColor="red"
title="这是一段内容确定删除吗?"
>
<template #reference>
<el-button>删除</el-button>
</template>
</el-popconfirm>
</template>

触发事件

点击按钮触发事件

<template>
<el-popconfirm
confirmButtonText="确定"
cancelButtonText="取消"
icon="el-icon-info"
iconColor="red"
title="这是一段内容确定删除吗?"
@confirm="confirmEvent"
@cancel="cancelEvent"
>
<template #reference>
<el-button>删除</el-button>
</template>
</el-popconfirm>
</template>
<script>
export default {
methods: {
confirmEvent() {
console.log('confirm!')
},
cancelEvent() {
console.log('cancel!')
},
},
}
</script>

Attributes

参数说明类型可选值默认值
title标题String
confirmButtonText确认按钮文字String
cancelButtonText取消按钮文字String
confirmButtonType确认按钮类型StringPrimary
cancelButtonType取消按钮类型StringText
iconIconStringel-icon-question
iconColorIcon 颜色String#f90
hideIcon是否隐藏 IconBooleanfalse

Slot

参数说明
reference触发 Popconfirm 显示的 HTML 元素

Events

事件名称说明回调参数
confirm点击确认按钮时触发
cancel点击取消按钮时触发