From d5fc7f9c30f287bb11a4fc883e68c8f2c4dd4dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6=E8=BF=9C=E6=96=B9?= Date: Tue, 12 Dec 2023 20:08:57 +0800 Subject: [PATCH] docs: update watchEffect --- src/api/reactivity-core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/reactivity-core.md b/src/api/reactivity-core.md index b68b0fa624..4be123fb3c 100644 --- a/src/api/reactivity-core.md +++ b/src/api/reactivity-core.md @@ -232,7 +232,7 @@ Takes an object (reactive or plain) or a [ref](#ref) and returns a readonly prox Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed. :::info Usage Note -`watchEffect` can only observe dependencies that are accessed during its initial execution. If you access reactive states within asynchronous operations, these states will not be collected as dependencies. Similarly, if you access these variables within an `if` statement and the condition is false during the initial execution, these variables will also not be collected as dependencies. +`watchEffect` will execute immediately upon initialization. During this initial execution, `watchEffect` will collect dependencies accessed during the first run. When the dependencies change, `watchEffect` will be re-executed. In subsequent executions, `watchEffect` will only collect dependencies accessed in the previous run, thus avoiding unnecessary executions and improving performance. ::: - **Type**