2021-09-04 19:29:28 +08:00
|
|
|
## Popconfirm
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
A simple confirmation dialog of an element click action.
|
|
|
|
|
|
|
|
### Basic usage
|
|
|
|
|
|
|
|
Popconfirm is similar to Popover. So for some duplicated attributes, please refer to the documentation of Popover.
|
|
|
|
|
|
|
|
:::demo Only `title` attribute is avaliable in Popconfirm, `content` will be ignored.
|
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 title="Are you sure to delete this?">
|
|
|
|
<template #reference>
|
|
|
|
<el-button>Delete</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
|
|
|
:::
|
|
|
|
|
|
|
|
### Customise
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
You can customise Popconfirm like:
|
|
|
|
:::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="OK"
|
|
|
|
cancelButtonText="No, Thanks"
|
|
|
|
icon="el-icon-info"
|
|
|
|
iconColor="red"
|
|
|
|
title="Are you sure to delete this?"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button>Delete</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
|
|
|
### Trigger event
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2021-08-18 11:06:22 +08:00
|
|
|
Click the button to trigger the event
|
|
|
|
|
|
|
|
:::demo
|
|
|
|
|
|
|
|
```html
|
|
|
|
<template>
|
|
|
|
<el-popconfirm
|
|
|
|
confirmButtonText="Yes"
|
|
|
|
cancelButtonText="No"
|
|
|
|
icon="el-icon-info"
|
|
|
|
iconColor="red"
|
|
|
|
title="Are you sure to delete this?"
|
|
|
|
@confirm="confirmEvent"
|
|
|
|
@cancel="cancelEvent"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button>Delete</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
|
|
|
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
| ----------------- | ------------------- | ------- | --------------- | ---------------- |
|
|
|
|
| title | Title | String | — | — |
|
|
|
|
| confirmButtonText | Confirm button text | String | — | — |
|
|
|
|
| cancelButtonText | Cancel button text | String | — | — |
|
|
|
|
| confirmButtonType | Confirm button type | String | — | Primary |
|
|
|
|
| cancelButtonType | Cancel button type | String | — | Text |
|
|
|
|
| icon | Icon | String | — | el-icon-question |
|
|
|
|
| iconColor | Icon color | String | — | #f90 |
|
|
|
|
| hideIcon | is hide Icon | Boolean | — | false |
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
### Slot
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Name | Description |
|
|
|
|
| --------- | ------------------------------------- |
|
2020-08-13 15:18:26 +08:00
|
|
|
| reference | HTML element that triggers Popconfirm |
|
|
|
|
|
|
|
|
### Events
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
| ---------- | ---------------------------------- | ---------- |
|
|
|
|
| confirm | triggers when click confirm button | — |
|
|
|
|
| cancel | triggers when click cancel button | — |
|