Member-only story
Understanding watch and watchEffect in Vue3

Vue series of articles
- Understanding v-memo in Vue3
- Understanding Suspense in Vue3
- Understanding reactive, isReactive and shallowReactive in Vue3
- Understanding defineModel in Vue3
- Understanding Fragment in Vue3
- Understanding Teleport in Vue3
- Understanding Async Components in Vue3
- Understanding v-model in Vue3
- Understanding watch and watchEffect in Vue3
- Understanding and Practice of the Vue3 Composition API
- Understanding Hooks in Vue3 (Why use hooks)
- Vue3- Use and Encapsulation Concept of Custom Hooks Functions
- Understanding the various ref in Vue3: toRef, toRefs, isRef, unref, etc
- Vue3 Development Solutions(Ⅰ)
- Vue3 Development Solutions(Ⅱ)
- The details about Vue3 that you didn’t know
- Vue3 develop document
- 28 Vue Interview Questions with Detailed Explanations
Differences between watch and watchEffect in Vue3
Features of watch:
Watch listening function can add configuration options, or it can be configured as empty. When the configuration option is empty, the characteristics of watch are as follows:
- Lazy: it does not execute immediately when it runs
- More specific: you need to add the property to listen to
Access to previous values the property: the callback function will return the latest value and the value before modification - Configurable: configuration items can supplement the shortcomings of watch functions
(1) immediate
: configure whether the watch property executes immediately. When the value is true, it executes immediately once it runs. When the value is false, it remains lazy
(2) deep
: configure whether watch listens deeply. When the value is true, it can listen to all properties of the object. When the value is false, it remains more specific and must be…