[improvement] support functional component model prop (#2758)

This commit is contained in:
neverland 2019-02-16 11:10:40 +08:00 committed by GitHub
parent 9aee819c29
commit f6ab03fa7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,20 +11,31 @@ import Vue, {
RenderContext
} from 'vue/types';
import { VNode, ScopedSlot } from 'vue/types/vnode';
import { InjectOptions, PropsDefinition } from 'vue/types/options';
type VantComponentOptions = ComponentOptions<Vue> & {
functional?: boolean;
install?: (Vue: VueConstructor) => void;
};
type VantPureComponent = {
type DefaultProps = Record<string, any>;
type VantPureComponent<
Props = DefaultProps,
PropDefs = PropsDefinition<Props>
> = {
(
h: CreateElement,
props: { [key: string]: any },
slots: { [key: string]: ScopedSlot | undefined },
context: RenderContext
): VNode;
props: any;
props?: PropDefs;
model?: {
prop?: string;
event?: string;
};
inject?: InjectOptions;
};
const arrayProp = {
@ -73,6 +84,7 @@ function transformPureComponent(pure: VantPureComponent): VantComponentOptions {
return {
functional: true,
props: pure.props,
model: pure.model,
render: (h, context) => pure(h, context.props, unifySlots(context), context)
};
}