Skip to content
Discussion options

You must be logged in to vote

See #9759 (comment)

This behavior is expected. Within defineModel, the value of modelValue is changed through event notifications, and it is modified by the parent component. When it changes, it triggers the update of the component. Since component updates are asynchronous, you must wait until the component is updated to obtain the latest value. You can use nextTick to retrieve the most up-to-date value.

const addNum = async ()=>{
  modelValue.value = modelValue.value+1
  await nextTick()
  alert(modelValue.value)
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by baiwusanyu-c
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants