UNPKG

2.02 kBPlain TextView Raw
1<template>
2 <el-popover
3 v-bind="$attrs"
4 v-model="visible"
5 trigger="click"
6 >
7 <div class="el-popconfirm">
8 <p class="el-popconfirm__main">
9 <i
10 v-if="!hideIcon"
11 :class="icon"
12 class="el-popconfirm__icon"
13 :style="{color: iconColor}"
14 ></i>
15 {{title}}
16 </p>
17 <div class="el-popconfirm__action">
18 <el-button
19 size="mini"
20 :type="cancelButtonType"
21 @click="cancel"
22 >
23 {{ displayCancelButtonText }}
24 </el-button>
25 <el-button
26 size="mini"
27 :type="confirmButtonType"
28 @click="confirm"
29 >
30 {{ displayConfirmButtonText }}
31 </el-button>
32 </div>
33 </div>
34 <slot name="reference" slot="reference"></slot>
35</el-popover>
36</template>
37
38<script>
39import ElPopover from 'element-ui/packages/popover';
40import ElButton from 'element-ui/packages/button';
41import {t} from 'element-ui/src/locale';
42
43export default {
44 name: 'ElPopconfirm',
45 props: {
46 title: {
47 type: String
48 },
49 confirmButtonText: {
50 type: String
51 },
52 cancelButtonText: {
53 type: String
54 },
55 confirmButtonType: {
56 type: String,
57 default: 'primary'
58 },
59 cancelButtonType: {
60 type: String,
61 default: 'text'
62 },
63 icon: {
64 type: String,
65 default: 'el-icon-question'
66 },
67 iconColor: {
68 type: String,
69 default: '#f90'
70 },
71 hideIcon: {
72 type: Boolean,
73 default: false
74 }
75 },
76 components: {
77 ElPopover,
78 ElButton
79 },
80 data() {
81 return {
82 visible: false
83 };
84 },
85 computed: {
86 displayConfirmButtonText() {
87 return this.confirmButtonText || t('el.popconfirm.confirmButtonText');
88 },
89 displayCancelButtonText() {
90 return this.cancelButtonText || t('el.popconfirm.cancelButtonText');
91 }
92 },
93 methods: {
94 confirm() {
95 this.visible = false;
96 this.$emit('confirm');
97 },
98 cancel() {
99 this.visible = false;
100 this.$emit('cancel');
101 }
102 }
103};
104</script>