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

$nextTick don't work as expected #2282

Closed
shaan1974 opened this issue Sep 30, 2020 · 3 comments
Closed

$nextTick don't work as expected #2282

shaan1974 opened this issue Sep 30, 2020 · 3 comments
Labels
has PR A pull request has already been submitted to solve the issue has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working

Comments

@shaan1974
Copy link

Version

3.0.0

Reproduction link

https://jsfiddle.net/shaan1974/rokqebcL/

Steps to reproduce

Just click on the Button "Change LG" and take a look into the console. "This" var ( line #17) inside the nextTick is the window object and not the current instance.

What is expected?

"This" should be the current instance

What is actually happening?

"This" is the Window object


To see how it's work with Vue 2 and 3 i'v created two fiddle.

Vuejs 2 ex => https://jsfiddle.net/shaan1974/qf4umgh2/
Vuejs 3 ex => https://jsfiddle.net/shaan1974/rokqebcL/

@posva
Copy link
Member

posva commented Sep 30, 2020

I'm surprised it works on Vue 2. You should use an arrow function to keep the context or even use the promise syntax. I thought the callback syntax wouldn't be supported anymore

@posva posva added the has workaround A workaround has been found to avoid the problem label Sep 30, 2020
@LinusBorg
Copy link
Member

We should keep it compatible though, seems like an easy fix.

@LinusBorg LinusBorg added the 🐞 bug Something isn't working label Sep 30, 2020
@shaan1974
Copy link
Author

Thanks guys with arrow function it's working ;)

antfu added a commit to antfu/vue-next that referenced this issue Oct 1, 2020
@LinusBorg LinusBorg added the has PR A pull request has already been submitted to solve the issue label Oct 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR A pull request has already been submitted to solve the issue has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants