Skip to content

Commit 808dcd1

Browse files
committed
fix(types): add model option to functional components
Closes vuejs#8210
1 parent 5e3823a commit 808dcd1

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;

types/test/options-test.ts

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

353+
Vue.component('functional-component-v-model', {
354+
props: ['foo'],
355+
functional: true,
356+
model: {
357+
prop: 'foo',
358+
event: 'change'
359+
},
360+
render(createElement, context) {
361+
return createElement("input", {
362+
on: {
363+
input: new Function()
364+
},
365+
domProps: {
366+
value: context.props.foo
367+
}
368+
});
369+
}
370+
});
371+
372+
353373
Vue.component('async-es-module-component', () => import('./es-module'))

0 commit comments

Comments
 (0)