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

<template>
<el-popconfirm
width="220"
:icon="InfoFilled"
icon-color="#626AEF"
title="Are you sure to delete this?"
@cancel="onCancel"
>
<template #reference>
<el-button>Delete</el-button>
</template>
<template #actions="{ confirm, cancel }">
<el-button size="small" @click="cancel">No!</el-button>
<el-button
type="danger"
size="small"
:disabled="!clicked"
@click="confirm"
>
Yes?
</el-button>
</template>
</el-popconfirm>
</template>
<script setup>
import { ref } from 'vue'
import { InfoFilled } from '@element-plus/icons-vue'
const clicked = ref(false)
function onCancel() {
clicked.value = true
}
</script>
<template>
<el-popconfirm
confirm-button-text="Yes"
cancel-button-text="No"
:icon="InfoFilled"
icon-color="#626AEF"
title="Are you sure to delete this?"
@confirm="confirmEvent"
@cancel="cancelEvent"
>
<template #reference>
<el-button>Delete</el-button>
</template>
</el-popconfirm>
</template>
<script setup>
import { InfoFilled } from '@element-plus/icons-vue'
const confirmEvent = () => {
console.log('confirm!')
}
const cancelEvent = () => {
console.log('cancel!')
}
</script>| 属性名 | 说明 | 类型 | 默认 |
|---|---|---|---|
| title | 标题 | string | — |
| confirm-button-text | 确认按钮文字 | string | — |
| cancel-button-text | 取消按钮文字 | string | — |
| confirm-button-type | 确认按钮类型 | enum | primary |
| cancel-button-type | 取消按钮类型 | enum | text |
| icon | 自定义图标 | string / Component | QuestionFilled |
| icon-color | Icon 颜色 | string | #f90 |
| hide-icon | 是否隐藏 Icon | boolean | false |
| hide-after | 关闭时的延迟 | number | 200 |
| teleported | 是否将 popover 的下拉列表插入至 body 元素 | boolean | true |
| persistent | 当 popover 组件长时间不触发且 persistent 属性设置为 false 时, popover 将会被删除 | boolean | false |
| width | 弹层宽度,最小宽度 150px | string / number | 150 |
| 事件名 | 说明 | 类型 |
|---|---|---|
| confirm | 点击确认按钮时触发 | Function |
| cancel | 点击取消按钮时触发 | Function |
| 插槽名 | 说明 | 类型 |
|---|---|---|
| reference | 触发 Popconfirm 显示的 HTML 元素 | — |
| actions 2.8.1 | 页脚的内容 | object |
站长微信:xiaomao0055
站长QQ:14496453