Skip to content

Commit 6307a13

Browse files
posvaaJean
authored andcommitted
types: add model option to functional components (vuejs#8212)
Closes vuejs#8210
1 parent 4b15e05 commit 6307a13

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

types/options.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ export interface ComponentOptions<
111111
export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> {
112112
name?: string;
113113
props?: PropDefs;
114+
model?: {
115+
prop?: string;
116+
event?: string;
117+
};
114118
inject?: InjectOptions;
115119
functional: boolean;
116120
render?(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode | VNode[];

types/test/options-test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,24 @@ Vue.component("async-component", ((resolve, reject) => {
376376
})
377377
}));
378378

379+
Vue.component('functional-component-v-model', {
380+
props: ['foo'],
381+
functional: true,
382+
model: {
383+
prop: 'foo',
384+
event: 'change'
385+
},
386+
render(createElement, context) {
387+
return createElement("input", {
388+
on: {
389+
input: new Function()
390+
},
391+
domProps: {
392+
value: context.props.foo
393+
}
394+
});
395+
}
396+
});
397+
398+
379399
Vue.component('async-es-module-component', () => import('./es-module'))

0 commit comments

Comments
 (0)