Skip to content

Vue动态监听,computed与watch的取舍 #23

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

Open
heightzhang opened this issue Aug 1, 2017 · 0 comments
Open

Vue动态监听,computed与watch的取舍 #23

heightzhang opened this issue Aug 1, 2017 · 0 comments
Labels

Comments

@heightzhang
Copy link
Owner

computed
watch

watch用于观察属性发送变化后,做额外处理。
与computed属性的差别在于作用对象不同,watch观察变化的源头,而computed属性是变化的目标,当然,两者可以互相转换。两者如何取舍在于:变化的源与目标哪部分的属性更多,如果多个源属性变化影响一个目标属性则建议使用computed;相反,如一个源属性变化影响了多个目标属性,则建议采用watch。

参考来源:Vue相关属性总结

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