File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import {
31
31
import { warn } from './warning'
32
32
import { SlotsType , StrictUnwrapSlotsType } from './componentSlots'
33
33
import { Ref , ref } from '@vue/reactivity'
34
- import { watch } from './apiWatch'
34
+ import { watch , watchSyncEffect } from './apiWatch'
35
35
36
36
// dev only
37
37
const warnRuntimeUsage = ( method : string ) =>
@@ -378,18 +378,20 @@ export function useModel(
378
378
379
379
if ( options && options . local ) {
380
380
const proxy = ref < any > ( props [ name ] )
381
+ watchSyncEffect ( ( ) => {
382
+ proxy . value = props [ name ]
383
+ } )
381
384
382
385
watch (
383
- ( ) => props [ name ] ,
384
- v => ( proxy . value = v )
386
+ proxy ,
387
+ value => {
388
+ if ( value !== props [ name ] ) {
389
+ i . emit ( `update:${ name } ` , value )
390
+ }
391
+ } ,
392
+ { flush : 'sync' }
385
393
)
386
394
387
- watch ( proxy , value => {
388
- if ( value !== props [ name ] ) {
389
- i . emit ( `update:${ name } ` , value )
390
- }
391
- } )
392
-
393
395
return proxy
394
396
} else {
395
397
return {
You can’t perform that action at this time.
0 commit comments