[Vuejs]-How can I reset the value of a ref and keep an associated watcher working?

3👍

  1. When watching a ref, use the ref itself — not its value property — as the watch source (the 1st argument to watch()).

  2. To observe new array assignments or item additions/removals, pass the deep:true option (the 3rd argument to watch()):

watch(
  myArray 1️⃣,
  () => { /* handle change */ },
  { deep: true } 2️⃣
)

demo

👤tony19

Leave a comment