SoFunction
Updated on 2025-04-05

NextTick method is used in vue3.0

Here is a comparison of the methods of 3.0 and 2.0

nextTick is to postpone the callback until after the next DOM update cycle.

Use it immediately after changing some data to wait for the DOM to update

vue3.0

1. Introduce

import { nextTick } from 'vue'

2. Use it in detail, in conjunction with asynchronous

setup() {
    const message = ref('Hello!')
    const changeMessage = async newMessage => {
       = newMessage
      await nextTick()
      ('Now DOM is updated')
    }
  }

3. Specific use, ordinary

Method:

 setup () {    
    let otherParam = reactive({
      showA:false
    })
    nextTick(()=>{
       = true
    })
  return {
      otherParam
 
    }
 
 
}

On the page:

<a-boo v-if=""></a-boo>

vue2.0

 = false
this.$nextTick(() =&gt; {
   //The method you want to execute      = true
})

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.