defineModel is Synchronous or Asynchronous ? #13312
Replies: 2 comments 1 reply
-
|
https://github.com/vuejs/core/issues?q=is%3Aissue%20state%3Aclosed%20defineModel%20nextTick |
Beta Was this translation helpful? Give feedback.
-
|
For more explanation of why the While
The key thing to note is that microtasks queued by a listener for a DOM event will run before other listeners for the same event. For
Are you able to provide a reproduction for this, as it doesn't seem to be happening in the Playground you shared. I'm unclear what the constraints are for your real use case, but here's a Playground that dodges the problems in your original example: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I often encounter the issue of
emitsoutputting the old value when modifying props throughdefineModel. In this test, I've observeddefineModelexhibiting both asynchronous and synchronous behavior.Sometimes, when the parent component receives the
emitsand then accesses the ref value, it also gets the old value.If I want my child component to ensure that the parent component's ref value is the new value after emitting, how should I write the code?
https://play.vuejs.org/#eNqNVNGOmzAQ/JWVVcmcmoJK+xQl0bVRHq5S76r23uqqR8km4c4YBCaNhPj3rm1IIJegPsX2jNczy05q9inP/X2FbMpmZVwkuYYSdZUvhErSPCs0LHeJXMOmyFLgfhCbnbnAj4QaCtxA01IcJFScqVKDxoN+D3PD8Pg9vzkhmVruIrXFx5bh4Q3MF1ALBWAYmURfZlvvyZaYwpvaLvx9JCtsnqjSGQ8NxyHNUEDYCbj2viGMvh9274f/+/4scN2kPtJGY5rLSCPtAGauo2YJsH+XZmuUU2tuLpj9FewCGrZoeERv41MHCRx09BLJVBjYFsxxFrPAaiJ5s6CnlU2YLsnkJtn6z2WmaEhsfwSLszRPJBYPuU6oCYJNXecMFkmZ/f1iz3RR4aQ7j3cYv1w4fy4P5kywbwWWWOxRsCOmo2KL2sGrH/ckugdSbypJ7BHwO9IHqoxGR/tcqTXJ7vGs2js7yYnaPparg0ZVdqaMUMNsLF8wmu7liPWT3A/+R3uPhoG6eEzN9ZjVsMZNovCr+eBX0oRpokuaVcdcmZ33k/emgE+gtw35r97A/+6y2HvH4/aQT2o6jCqpp8B5M0yJTOIXk49TPFwllwRCBtu3wB9I8Vk2HMUEpE9uU2RdeWc2+rxhoi1iEvvKR0j3jkbOfdypvNJDH68l2py71bhE81Sf10kci/2fSutMUSBNR10UzUowCwPUdeu6oVLED9yF9nIBgVsl1kj7z0BlnAzK+61FbGFrlo7MlWGim39DDADw
Beta Was this translation helpful? Give feedback.
All reactions