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 与 watchEffect 的区别 #5

Open
chengnan114 opened this issue Feb 7, 2023 · 0 comments
Open

watch 与 watchEffect 的区别 #5

chengnan114 opened this issue Feb 7, 2023 · 0 comments

Comments

@chengnan114
Copy link
Owner

watchEffect 将在方法的任何依赖项发生更改时运行,watch 跟踪一个或多个特定的响应性属性,并且仅在该属性发生更改时运行。
watchEffect在使用时,传入的函数会立刻执行一次。watch默认情况下并不会执行回调函数,除非我们手动设置immediate选项。
从实现上来说,watchEffect(fn)相当于watch(fn,fn,{immediate:true}),watchEffect就是一种特殊的watch实现。

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

No branches or pull requests

1 participant