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

computed、methods、watch的区别? #130

Open
GGXXMM opened this issue Apr 2, 2023 · 0 comments
Open

computed、methods、watch的区别? #130

GGXXMM opened this issue Apr 2, 2023 · 0 comments
Labels

Comments

@GGXXMM
Copy link
Owner

GGXXMM commented Apr 2, 2023

  • computed,是计算属性,具有缓存性(惰性求值观察者),只有响应式依赖发生改变,才会重新计算。

  • methods,每次调用都会执行函数。

  • watch,是侦听属性,监听到数据变化就会执行回调,在回调可以进行一些逻辑操作。

总结

从使用场景上来说,computed适用:一个数据被多个数据影响;而watch适用:一个数据影响多个数据。

@GGXXMM GGXXMM added the vue label Apr 2, 2023
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

1 participant