mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 01:41:20 +08:00
19fa2900dd
* Added an example of the popconfirm button click event(for all languages) * Fixed the problem of indent. Co-authored-by: 逝水经年 <entireyu@jniantic.cn>
102 lines
2.4 KiB
Markdown
102 lines
2.4 KiB
Markdown
## Popconfirm
|
|
|
|
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.
|
|
```html
|
|
<template>
|
|
<el-popconfirm
|
|
title="Are you sure to delete this?"
|
|
>
|
|
<template #reference>
|
|
<el-button>Delete</el-button>
|
|
</template>
|
|
</el-popconfirm>
|
|
</template>
|
|
````
|
|
:::
|
|
|
|
### Customise
|
|
You can customise Popconfirm like:
|
|
:::demo
|
|
```html
|
|
<template>
|
|
<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>
|
|
</template>
|
|
```
|
|
:::
|
|
|
|
### Trigger event
|
|
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>
|
|
export default {
|
|
methods: {
|
|
confirmEvent() {
|
|
console.log("confirm!");
|
|
},
|
|
cancelEvent() {
|
|
console.log("cancel!");
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
```
|
|
|
|
:::
|
|
|
|
### Attributes
|
|
| 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 |
|
|
|
|
### Slots
|
|
| Name | Description |
|
|
|--- | ---|
|
|
| reference | HTML element that triggers Popconfirm |
|
|
|
|
### Events
|
|
| Event Name | Description | Parameters |
|
|
|---------|--------|---------|
|
|
| confirm | triggers when click confirm button | — |
|
|
| cancel | triggers when click cancel button | — | |