Skip to content

Commit bdce299

Browse files
wangyi7099chrisvfritz
authored andcommitted
Add watch usages (vuejs#1356)
* Add watch usages! Add `watch` usages! * Update index.md * tweaks to watch api examples
1 parent 9163da0 commit bdce299

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/v2/api/index.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ type: api
592592

593593
### watch
594594

595-
- **Type:** `{ [key: string]: string | Function | Object }`
595+
- **Type:** `{ [key: string]: string | Function | Object | Array}`
596596

597597
- **Details:**
598598

@@ -606,7 +606,12 @@ type: api
606606
a: 1,
607607
b: 2,
608608
c: 3,
609-
d: 4
609+
d: 4,
610+
e: {
611+
f: {
612+
g: 5
613+
}
614+
}
610615
},
611616
watch: {
612617
a: function (val, oldVal) {
@@ -623,7 +628,13 @@ type: api
623628
d: {
624629
handler: function (val, oldVal) { /* ... */ },
625630
immediate: true
626-
}
631+
},
632+
e: [
633+
function handle1 (val, oldVal) { /* ... */ },
634+
function handle2 (val, oldVal) { /* ... */ }
635+
],
636+
// watch vm.e.f's value: {g: 5}
637+
'e.f': function (val, oldVal) { /* ... */ }
627638
}
628639
})
629640
vm.a = 2 // => new: 2, old: 1

0 commit comments

Comments
 (0)