>>;
@@ -61,7 +65,7 @@ const Popconfirm = defineComponent({
disabled: false,
}),
slots: ['title', 'content', 'okText', 'icon', 'cancelText', 'cancelButton', 'okButton'],
- emits: ['update:visible', 'confirm', 'cancel', 'visibleChange'],
+ emits: ['update:visible', 'visibleChange'],
setup(props: PopconfirmProps, { slots, emit, expose }) {
onMounted(() => {
devWarning(
@@ -71,7 +75,6 @@ const Popconfirm = defineComponent({
);
});
const tooltipRef = ref();
-
expose({
getPopupDomNode: () => {
return tooltipRef.value?.getPopupDomNode?.();
@@ -91,14 +94,17 @@ const Popconfirm = defineComponent({
emit('visibleChange', value, e);
};
- const onConfirm = (e: MouseEvent) => {
+ const close = (e: MouseEvent) => {
settingVisible(false, e);
- emit('confirm', e);
+ };
+
+ const onConfirm = (e: MouseEvent) => {
+ return props.onConfirm?.(e);
};
const onCancel = (e: MouseEvent) => {
settingVisible(false, e);
- emit('cancel', e);
+ props.onCancel?.(e);
};
const onKeyDown = (e: KeyboardEvent) => {
@@ -114,9 +120,10 @@ const Popconfirm = defineComponent({
}
settingVisible(value);
};
- const { prefixCls: prefixClsConfirm, configProvider } = useConfigInject('popconfirm', props);
- const rootPrefixCls = computed(() => configProvider.getPrefixCls());
- const popoverPrefixCls = computed(() => configProvider.getPrefixCls('popover'));
+ const { prefixCls: prefixClsConfirm, getPrefixCls } = useConfigInject('popconfirm', props);
+ const rootPrefixCls = computed(() => getPrefixCls());
+ const popoverPrefixCls = computed(() => getPrefixCls('popover'));
+ const btnPrefixCls = computed(() => getPrefixCls('btn'));
const [popconfirmLocale] = useLocaleReceiver('Popconfirm', defaultLocale.Popconfirm);
const renderOverlay = () => {
const {
@@ -127,6 +134,7 @@ const Popconfirm = defineComponent({
okText = slots.okText?.(),
okType,
icon = slots.icon?.(),
+ showCancel = true,
} = props;
const { cancelButton, okButton } = slots;
const cancelProps: ButtonProps = {
@@ -147,15 +155,26 @@ const Popconfirm = defineComponent({
{title}
@@ -170,6 +189,8 @@ const Popconfirm = defineComponent({
'cancelText',
'okText',
'onUpdate:visible',
+ 'onConfirm',
+ 'onCancel',
]);
const overlayClassNames = classNames(prefixClsConfirm.value, overlayClassName);
return (
diff --git a/components/popconfirm/index.zh-CN.md b/components/popconfirm/index.zh-CN.md
index c70cd67e1..4802b440d 100644
--- a/components/popconfirm/index.zh-CN.md
+++ b/components/popconfirm/index.zh-CN.md
@@ -23,6 +23,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/fjMCD9xRq/Popconfirm.svg
| okText | 确认按钮文字 | string\|slot | 确定 | |
| okButton | 完全自定义确认按钮 | slot | - | 3.0 |
| okType | 确认按钮类型 | string | primary | |
+| showCancel | 是否显示取消按钮 | boolean | true | 3.0 |
| title | 确认框的描述 | string\|slot | 无 | |
| visible (v-model) | 是否显示 | boolean | - | |
| icon | 自定义弹出气泡 Icon 图标 | vNode | <Icon type="exclamation-circle" /> | |