@@ -18,6 +18,7 @@ export default (ComponentStyle) => {
1818 props : {
1919 as : [ String , Object ] ,
2020 value : null ,
21+ modelValue : null ,
2122
2223 ...currentProps ,
2324 ...prevProps
@@ -31,7 +32,7 @@ export default (ComponentStyle) => {
3132
3233 data ( ) {
3334 return {
34- localValue : this . value
35+ localValue : this . modelValue || this . value
3536 }
3637 } ,
3738
@@ -41,17 +42,35 @@ export default (ComponentStyle) => {
4142 if ( propName === 'as' && isStringTarget ) {
4243 return props
4344 }
44- if ( this . $props [ propName ] ) {
45+ if ( this . $props [ propName ] !== undefined ) {
4546 props [ propName ] = this . $props [ propName ]
4647 }
4748 return props
4849 } , { } )
50+ } ,
51+ valueProps ( ) {
52+ if ( this . modelValue === undefined && this . value === undefined ) {
53+ return { }
54+ }
55+
56+ return {
57+ value : this . localValue ,
58+ onInput : event => {
59+ if ( event && event . target ) {
60+ this . localValue = event . target . value
61+ }
62+ }
63+ }
4964 }
5065 } ,
5166
5267 watch : {
5368 localValue ( val ) {
54- this . $emit ( 'update:value' , val )
69+ if ( this . modelValue !== undefined ) {
70+ this . $emit ( 'update:modelValue' , val )
71+ } else {
72+ this . $emit ( 'update:value' , val )
73+ }
5574 }
5675 } ,
5776
@@ -62,13 +81,9 @@ export default (ComponentStyle) => {
6281 isVueComponent ( target ) ? target : this . $props . as || target ,
6382 {
6483 ...this . passProps ,
65- class : [ styleClass ] ,
66- value : this . localValue ,
67- onInput : event => {
68- if ( event && event . target ) {
69- this . localValue = event . target . value
70- }
71- }
84+ ...this . valueProps ,
85+ ...this . $attrs ,
86+ class : [ styleClass ]
7287 } ,
7388 this . $slots
7489 )
0 commit comments