You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/vc-dialog/DialogWrap.jsx

50 lines
1.2 KiB

import Dialog from './Dialog';
import getDialogPropTypes from './IDialogPropTypes';
import Portal from '../_util/PortalWrapper';
import { getSlot } from '../_util/props-util';
import { defineComponent } from 'vue';
const IDialogPropTypes = getDialogPropTypes();
const DialogWrap = defineComponent({
inheritAttrs: false,
props: {
...IDialogPropTypes,
visible: IDialogPropTypes.visible.def(false),
},
render() {
const { visible, getContainer, forceRender } = this.$props;
let dialogProps = {
...this.$props,
...this.$attrs,
ref: '_component',
key: 'dialog',
};
// 渲染在当前 dom 里;
if (getContainer === false) {
return (
<Dialog
{...dialogProps}
getOpenCount={() => 2} // body
>
{getSlot(this)}
</Dialog>
);
}
return (
<Portal
visible={visible}
forceRender={forceRender}
getContainer={getContainer}
v-slots={{
default: childProps => {
dialogProps = { ...dialogProps, ...childProps };
return <Dialog {...dialogProps}>{getSlot(this)}</Dialog>;
},
}}
/>
);
},
});
export default DialogWrap;