Skip to content

Commit 3d3884b

Browse files
committed
fix: form.create lose slots #1998
1 parent 33175ec commit 3d3884b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

components/_util/vnode.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { filterEmpty, parseStyleText } from './props-util';
22
import classNames from 'classnames';
3-
import { warning } from '../vc-util/warning';
43

54
export function cloneVNode(vnode, deep) {
65
const componentOptions = vnode.componentOptions;

components/vc-form/src/createBaseForm.jsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ function createBaseForm(option = {}, mixins = []) {
710710
},
711711

712712
render() {
713-
const { $slots } = this;
713+
const { $slots, $scopedSlots } = this;
714714
const formProps = {
715715
[formPropName]: this.getForm(),
716716
};
@@ -729,9 +729,18 @@ function createBaseForm(option = {}, mixins = []) {
729729
},
730730
],
731731
};
732-
732+
if (Object.keys($scopedSlots).length) {
733+
wrappedComponentProps.scopedSlots = $scopedSlots;
734+
}
735+
const slotsKey = Object.keys($slots);
733736
return WrappedComponent ? (
734-
<WrappedComponent {...wrappedComponentProps}>{$slots.default}</WrappedComponent>
737+
<WrappedComponent {...wrappedComponentProps}>
738+
{slotsKey.length
739+
? slotsKey.map(name => {
740+
return <template slot={name}>{$slots[name]}</template>;
741+
})
742+
: null}
743+
</WrappedComponent>
735744
) : null;
736745
},
737746
};

0 commit comments

Comments
 (0)