2020-08-13 15:18:26 +08:00
|
|
|
## Popconfirm 气泡确认框
|
|
|
|
|
|
|
|
点击元素,弹出气泡确认框。
|
|
|
|
|
|
|
|
### 基础用法
|
|
|
|
|
|
|
|
Popconfirm 的属性与 Popover 很类似,因此对于重复属性,请参考 Popover 的文档,在此文档中不做详尽解释。
|
|
|
|
:::demo 在 Popconfirm 中,只有 `title` 属性可用,`content` 属性不会被展示。
|
2021-08-18 11:06:22 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```html
|
|
|
|
<template>
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-popconfirm title="这是一段内容确定删除吗?">
|
|
|
|
<template #reference>
|
|
|
|
<el-button>删除</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
2020-08-13 15:18:26 +08:00
|
|
|
</template>
|
2021-09-04 19:29:28 +08:00
|
|
|
```
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### 自定义
|
|
|
|
|
|
|
|
可以在 Popconfirm 中自定义内容。
|
|
|
|
:::demo
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```html
|
|
|
|
<template>
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-popconfirm
|
|
|
|
confirmButtonText="好的"
|
|
|
|
cancelButtonText="不用了"
|
|
|
|
icon="el-icon-info"
|
|
|
|
iconColor="red"
|
|
|
|
title="这是一段内容确定删除吗?"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button>删除</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
2020-08-13 15:18:26 +08:00
|
|
|
</template>
|
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
2021-08-18 11:06:22 +08:00
|
|
|
### 触发事件
|
|
|
|
|
|
|
|
点击按钮触发事件
|
|
|
|
|
|
|
|
:::demo
|
|
|
|
|
|
|
|
```html
|
|
|
|
<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>
|
2021-09-04 19:29:28 +08:00
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
confirmEvent() {
|
|
|
|
console.log('confirm!')
|
|
|
|
},
|
|
|
|
cancelEvent() {
|
|
|
|
console.log('cancel!')
|
|
|
|
},
|
2021-08-18 11:06:22 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
2021-08-18 11:06:22 +08:00
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
### Attributes
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
| ----------------- | ------------- | ------- | ------ | ---------------- |
|
|
|
|
| title | 标题 | String | — | — |
|
|
|
|
| confirmButtonText | 确认按钮文字 | String | — | — |
|
|
|
|
| cancelButtonText | 取消按钮文字 | String | — | — |
|
|
|
|
| confirmButtonType | 确认按钮类型 | String | — | Primary |
|
|
|
|
| cancelButtonType | 取消按钮类型 | String | — | Text |
|
|
|
|
| icon | Icon | String | — | el-icon-question |
|
|
|
|
| iconColor | Icon 颜色 | String | — | #f90 |
|
|
|
|
| hideIcon | 是否隐藏 Icon | Boolean | — | false |
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
### Slot
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| 参数 | 说明 |
|
|
|
|
| --------- | -------------------------------- |
|
2020-08-13 15:18:26 +08:00
|
|
|
| reference | 触发 Popconfirm 显示的 HTML 元素 |
|
|
|
|
|
|
|
|
### Events
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| 事件名称 | 说明 | 回调参数 |
|
|
|
|
| -------- | ------------------ | -------- |
|
|
|
|
| confirm | 点击确认按钮时触发 | — |
|
|
|
|
| cancel | 点击取消按钮时触发 | — |
|