Member-only story

Understanding watch and watchEffect in Vue3

Shawn Kang
12 min readFeb 21, 2024

--

Vue series of articles

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…

--

--

Shawn Kang
Shawn Kang

Written by Shawn Kang

Focusing on front-end development and internet writing. Sharing technical tutorials and original fiction. https://skstory.online/

No responses yet

Write a response