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

watch and props changes are not in an update queue #1521

Closed
tangjinzhou opened this issue Jul 6, 2020 · 2 comments
Closed

watch and props changes are not in an update queue #1521

tangjinzhou opened this issue Jul 6, 2020 · 2 comments

Comments

@tangjinzhou
Copy link
Contributor

Version

3.0.0-beta.18

Reproduction link

https://jsbin.com/daxofotupi/edit?html,console,output

Steps to reproduce

input some characters and view the log, it will trigger two updates.

What is expected?

trigger one update

What is actually happening?

trigger two updates

@tangjinzhou
Copy link
Contributor Author

There is no problem for most scenes, but when using input, you will not be able to input Chinese like https://jsbin.com/neyuqekusi/edit?html,console,output .

@yyx990803
Copy link
Member

The watcher is triggered during the update of the child component itself and queued after. You can use a sync watcher:

  watch: {
    value: {
      handler(val) {
        console.log('watch value change')
        this.stateValue = val;
      },
      flush: 'sync'
    }
  }

Or, even better, use a computed instead of a watcher.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants