Change the text in the first (
testRefObj) input field.
Watch using a getter on an object property made reactive using
Console should log
watch testRefObj.text + the changed text.
Same as the second input (
watch deep testRefObj gets logged (watch with
deep: true on whole object, instead of a single property by getter)
It's stated here to use a getter to watch on a single property of an object, but this doesn't work: https://vuejs.org/guide/essentials/watchers.html#watch-source-types
deep: true is a workaround, but on objects with complex structures and more data, this will result in performance issues.
@Jackllllll Seems you're right, it works with
reactive() (updated example).
Maybe I didn't understand the difference to
ref(), I thought that I can't update the object (which I need to), but apart from not using the
.value syntax, it seems to work.
ref() should just call
reactive() on an object, as stated here: https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive-variables-with-ref
So maybe that's the real error here.
ref is just a nested layer of responsive value compared to
reactive, the important thing is not whether to use
reactive to define the value, but how you can make watch subscribe to it.
In the case, the get of
text is wrong, you should get the value defined on
|Issue Title||Created Date||Updated Date|