take a look at Vue"s API about watch options here, the code in the official tutorial:
var vm = new Vue({
data: {
a: 1,
b: 2,
c: 3,
d: 4,
e: {
f: {
g: 5
}
}
},
watch: {
a: function (val, oldVal) {
console.log("new: %s, old: %s", val, oldVal)
},
//
b: "someMethod",
// watcher
c: {
handler: function (val, oldVal) { /* ... */ },
deep: true
},
//
d: {
handler: function (val, oldVal) { /* ... */ },
immediate: true
},
e: [
function handle1 (val, oldVal) { /* ... */ },
function handle2 (val, oldVal) { /* ... */ }
],
// watch vm.e.f"s value: {g: 5}
"e.f": function (val, oldVal) { /* ... */ }
}
})
vm.a = 2 // => new: 2, old: 1
Where does the handler method appear in the example come from? It seems that you can"t replace
with another name.