3👍
✅
The watch source (i.e., model.value
) gets replaced in clear()
with an empty object, so the watcher no longer gets triggered.
Solution
-
Instead of unwrapping the
model
ref, pass theref
itself as the watch source. -
Pass the
deep
flag to the watch so that property addition/deletion is observed.
watch(
model, 1️⃣
(value) => { /* handle change */ },
{ deep: true } 2️⃣
)
Source:stackexchange.com