Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.nextTick() #28

Closed
kwanjas3 opened this issue Jul 10, 2019 · 8 comments
Closed

this.nextTick() #28

kwanjas3 opened this issue Jul 10, 2019 · 8 comments
Labels

Comments

@kwanjas3
Copy link

I have been relying on this for a significant part of a QA application I have been writing. Will this be available in some form or another in Vue 3? or should I begin rewriting things in .then()?

Thanks

@u3u
Copy link

u3u commented Jul 11, 2019

Defer the callback to be executed after the next DOM update cycle. Use it immediately after you’ve changed some data to wait for the DOM update. This is the same as the global Vue.nextTick, except that the callback’s this context is automatically bound to the instance calling this method.

https://vuejs.org/v2/api/#Vue-nextTick

@thommath
Copy link

I am not sure if it will be available in the Vue 3 API, but now it is available through the context.root element in this API.

setup(_, { root }) {
  root.$nextTick(() => console.log('hi'));
}

@kwanjas3
Copy link
Author

I am not sure if it will be available in the Vue 3 API, but now it is available through the context.root element in this API.

setup(_, { root }) {
  root.$nextTick(() => console.log('hi'));
}

thanks, still better than my solution of importing Vue to call Vue.nextTick(()=>{})

@posva
Copy link
Member

posva commented Jul 31, 2019

FYI, importing Vue to call Vue.nextTick is totally fine as a solution.
Not sure about how the usage of nextTick will be on v3 but it may be through a named import

Since root is part of the context and $nextTick is probably not going away, I would say using root.$nextTick is safe

@posva posva closed this as completed Jul 31, 2019
@posva posva added the question label Jul 31, 2019
@andrewspy
Copy link

Since root is deprecated in the setup() context, What's the correct way to invoke nextTick() inside setup?

@danielroe
Copy link
Member

@andrewspy You can import it directly from @vue/composition-api.

@ghost
Copy link

ghost commented Jun 19, 2021

Here you go - import { nextTick } from '@nuxtjs/composition-api';

@agm1984
Copy link

agm1984 commented Jun 28, 2021

I did:

import { nextTick } from 'vue'

...
await nextTick()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants