watch
-
Type:
Object
-
Details:
An object where keys are expressions to watch and values are the corresponding callbacks. The value can also be a string of a method name, or an Object that contains additional options. The Vue instance will call
$watch()
for each entry in the object at instantiation. -
Example:
var vm = new Vue({ data: { a: 1 }, watch: { 'a': function (val, oldVal) { console.log('new: %s, old: %s', val, oldVal) }, // string method name 'b': 'someMethod', // deep watcher 'c': { handler: function (val, oldVal) { /* ... */ }, deep: true } } }) vm.a = 2 // -> new: 2, old: 1
-
See also: Instance Methods - vm.$watch
Please login to continue.