fix: form.create lose slots #1998

pull/2005/head
tanjinzhou 2020-04-01 12:08:53 +08:00
parent 33175eca19
commit 3d3884bef3
2 changed files with 12 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import { filterEmpty, parseStyleText } from './props-util';
import classNames from 'classnames';
import { warning } from '../vc-util/warning';
export function cloneVNode(vnode, deep) {
const componentOptions = vnode.componentOptions;

View File

@ -710,7 +710,7 @@ function createBaseForm(option = {}, mixins = []) {
},
render() {
const { $slots } = this;
const { $slots, $scopedSlots } = this;
const formProps = {
[formPropName]: this.getForm(),
};
@ -729,9 +729,18 @@ function createBaseForm(option = {}, mixins = []) {
},
],
};
if (Object.keys($scopedSlots).length) {
wrappedComponentProps.scopedSlots = $scopedSlots;
}
const slotsKey = Object.keys($slots);
return WrappedComponent ? (
<WrappedComponent {...wrappedComponentProps}>{$slots.default}</WrappedComponent>
<WrappedComponent {...wrappedComponentProps}>
{slotsKey.length
? slotsKey.map(name => {
return <template slot={name}>{$slots[name]}</template>;
})
: null}
</WrappedComponent>
) : null;
},
};