You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/api/index.md
+101-2Lines changed: 101 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -364,9 +364,11 @@ type: api
364
364
// type check plus other validations
365
365
name: {
366
366
type:String,
367
+
default:0,
367
368
required:true,
368
-
// warn if not two way bound
369
-
twoWay:true
369
+
validator:function (value) {
370
+
return value >0
371
+
}
370
372
}
371
373
}
372
374
})
@@ -400,3 +402,100 @@ type: api
400
402
}
401
403
})
402
404
```
405
+
406
+
### computed
407
+
408
+
-**Type:**`Object`
409
+
410
+
-**Details:**
411
+
412
+
Computed properties to be mixed into the Vue instance. All getters and setters have their `this` context automatically bound to the Vue instance.
413
+
414
+
-**Example:**
415
+
416
+
```js
417
+
var vm =newVue({
418
+
data: { a:1 },
419
+
computed: {
420
+
// get only, just need a function
421
+
aDouble:function () {
422
+
returnthis.a*2
423
+
},
424
+
// both get and set
425
+
aPlus: {
426
+
get:function () {
427
+
returnthis.a+1
428
+
},
429
+
set:function (v) {
430
+
this.a= v -1
431
+
}
432
+
}
433
+
}
434
+
})
435
+
vm.aPlus// -> 2
436
+
vm.aPlus=3
437
+
vm.a// -> 2
438
+
vm.aDouble// -> 4
439
+
```
440
+
441
+
-**See also:**
442
+
-[Computed Properties](/guide/computed.html)
443
+
-[Reactivity in Depth: Inside Computed Properties](/guide/reactivity.html#Inside-Computed-Properties)
444
+
445
+
### methods
446
+
447
+
-**Type:**`Object`
448
+
449
+
-**Details:**
450
+
451
+
Methods to be mixed into the Vue instance. You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the Vue instance.
452
+
453
+
-**Example:**
454
+
455
+
```js
456
+
var vm =newVue({
457
+
data: { a:1 },
458
+
methods: {
459
+
plus:function () {
460
+
this.a++
461
+
}
462
+
}
463
+
})
464
+
vm.plus()
465
+
vm.a// 2
466
+
```
467
+
468
+
-**See also:**[Methods and Event Handling](/guide/events.html)
469
+
470
+
### watch
471
+
472
+
-**Type:**`Object`
473
+
474
+
-**Details:**
475
+
476
+
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.
0 commit comments