I
I
Ilya Kochkin2020-04-19 23:49:33
Vue.js
Ilya Kochkin, 2020-04-19 23:49:33

Is there a way to track changes to all data in vue?

The meaning of the question is that there is a vue instance

var app = new Vue({
el: '#app',
 data: {
  var1:1,
  var2:2,
  var3:3,
  ..
varN:N
  }
})

I need to track field changes and send the data to the server. Is there a universal way to track a change in any of the fields and call a function
, or do I need to hang a watch on each field

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Ponomarev, 2020-04-20
@mr_Koch

You can wrap it in an object and hang watch on this object


var1:1,
var2:2,
var3:3,
..
varN:N


form: {
var1:1,
var2:2,
var3:3,
..
varN:N
}

and add watch

watch: {
form: {
handler: function(newForm, oldForm) {...}
deep: true
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question