ant-design-vue/components/vc-dialog/DialogWrap.jsx

47 lines
1.1 KiB
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import Dialog from './Dialog';
import getDialogPropTypes from './IDialogPropTypes';
2020-05-13 10:36:53 +00:00
import Portal from '../_util/PortalWrapper';
2020-06-15 10:55:12 +00:00
import { getSlot } from '../_util/props-util';
2019-01-12 03:33:27 +00:00
const IDialogPropTypes = getDialogPropTypes();
2018-03-05 11:05:23 +00:00
const DialogWrap = {
2020-01-18 09:06:09 +00:00
inheritAttrs: false,
2018-03-05 11:05:23 +00:00
props: {
...IDialogPropTypes,
visible: IDialogPropTypes.visible.def(false),
},
2019-01-12 03:33:27 +00:00
render() {
2020-05-13 10:36:53 +00:00
const { visible, getContainer, forceRender } = this.$props;
2020-06-15 10:55:12 +00:00
let dialogProps = {
...this.$props,
...this.$attrs,
2020-05-13 10:36:53 +00:00
ref: '_component',
key: 'dialog',
};
// 渲染在当前 dom 里;
if (getContainer === false) {
return (
<Dialog
{...dialogProps}
getOpenCount={() => 2} // 不对 body 做任何操作。。
>
2020-06-15 10:55:12 +00:00
{getSlot(this)}
2020-05-13 10:36:53 +00:00
</Dialog>
);
}
2018-03-05 11:05:23 +00:00
return (
2020-05-13 10:36:53 +00:00
<Portal
2018-03-05 11:05:23 +00:00
visible={visible}
2020-05-13 10:36:53 +00:00
forceRender={forceRender}
getContainer={getContainer}
children={childProps => {
2020-06-15 10:55:12 +00:00
dialogProps = { ...dialogProps, ...childProps };
return <Dialog {...dialogProps}>{getSlot(this)}</Dialog>;
2018-03-05 11:05:23 +00:00
}}
2018-03-05 14:50:25 +00:00
/>
2019-01-12 03:33:27 +00:00
);
2018-03-05 11:05:23 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-03-05 11:05:23 +00:00
2019-01-12 03:33:27 +00:00
export default DialogWrap;