I have an input that uses the v-model
directive to control the data. I need to watch said data and figure out if it's been changed.
When I watch
the data, the new and old values are the same. This is because the data is mutated, as seen in the docs: https://vuejs.org/v2/api/#vm-watch
Note: when mutating (rather than replacing) an Object or an Array, the old value will be the same as new value because they reference the same Object/Array. Vue doesn’t keep a copy of the pre-mutate value.
How do I use v-model
and NOT mutate the data?