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
-**Restriction:** Only accepts `Function` when used in a component definition.
314
+
-**限制:** Only accepts `Function` when used in a component definition.
315
315
316
-
-**Details:**
316
+
-**详细:**
317
317
318
318
The data object for the Vue instance. Vue will recursively convert its properties into getter/setters to make it "reactive". **The object must be plain**: native objects such as browser API objects and prototype properties are ignored. A rule of thumb is that data should just be data - it is not recommended to observe objects with its own stateful behavior.
319
319
@@ -327,7 +327,7 @@ type: api
327
327
328
328
If required, a deep clone of the original object can be obtained by passing `vm.$data` through `JSON.parse(JSON.stringify(...))`.
329
329
330
-
-**Example:**
330
+
-**示例:**
331
331
332
332
```js
333
333
var data = { a:1 }
@@ -349,17 +349,17 @@ type: api
349
349
350
350
<pclass="tip">Note that __you should not use an arrow function with the `data` property__ (e.g. `data: () => { return { a: this.myProp }}`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.myProp` will be undefined.</p>
351
351
352
-
-**See also:**[Reactivity in Depth](/guide/reactivity.html)
352
+
-**另见:**[深入响应式原理h](/guide/reactivity.html)
353
353
354
354
### props
355
355
356
-
-**Type:**`Array<string> | Object`
356
+
-**类型:**`Array<string> | Object`
357
357
358
-
-**Details:**
358
+
-**详细:**
359
359
360
360
A list/hash of attributes that are exposed to accept data from the parent component. It has a simple Array-based syntax and an alternative Object-based syntax that allows advanced configurations such as type checking, custom validation and default values.
-**Restriction:** only respected in instance creation via `new`.
394
+
-**限制:** only respected in instance creation via `new`.
395
395
396
-
-**Details:**
396
+
-**详细:**
397
397
398
398
Pass props to an instance during its creation. This is primarily intended to make unit testing easier.
399
399
400
-
-**Example:**
400
+
-**示例:**
401
401
402
402
```js
403
403
var Comp =Vue.extend({
@@ -414,17 +414,17 @@ type: api
414
414
415
415
### computed
416
416
417
-
-**Type:**`{ [key: string]: Function | { get: Function, set: Function } }`
417
+
-**类型:**`{ [key: string]: Function | { get: Function, set: Function } }`
418
418
419
-
-**Details:**
419
+
-**详细:**
420
420
421
421
Computed properties to be mixed into the Vue instance. All getters and setters have their `this` context automatically bound to the Vue instance.
422
422
423
423
<pclass="tip">Note that __you should not use an arrow function to define a computed property__ (e.g. `aDouble: () => this.a * 2`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.</p>
424
424
425
425
Computed properties are cached, and only re-computed on reactive dependency changes.
426
426
427
-
-**Example:**
427
+
-**示例:**
428
428
429
429
```js
430
430
var vm =newVue({
@@ -451,20 +451,20 @@ type: api
451
451
vm.aDouble// -> 4
452
452
```
453
453
454
-
-**See also:**
455
-
-[Computed Properties](/guide/computed.html)
454
+
-**另见:**
455
+
-[计算属性](/guide/computed.html)
456
456
457
457
### methods
458
458
459
-
-**Type:**`{ [key: string]: Function }`
459
+
-**类型:**`{ [key: string]: Function }`
460
460
461
-
-**Details:**
461
+
-**详细:**
462
462
463
463
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.
464
464
465
465
<pclass="tip">Note that __you should not use an arrow function to define a method__ (e.g. `plus: () => this.a++`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.</p>
466
466
467
-
-**Example:**
467
+
-**示例:**
468
468
469
469
```js
470
470
var vm =newVue({
@@ -479,17 +479,17 @@ type: api
479
479
vm.a// 2
480
480
```
481
481
482
-
-**See also:**[Methods and Event Handling](/guide/events.html)
482
+
-**另见:**[方法与事件处理器](/guide/events.html)
483
483
484
484
### watch
485
485
486
-
-**Type:**`{ [key: string]: string | Function | Object }`
486
+
-**类型:**`{ [key: string]: string | Function | Object }`
487
487
488
-
-**Details:**
488
+
-**详细:**
489
489
490
490
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.
491
491
492
-
-**Example:**
492
+
-**示例:**
493
493
494
494
```js
495
495
var vm =newVue({
@@ -516,7 +516,7 @@ type: api
516
516
517
517
<pclass="tip">Note that __you should not use an arrow function to define a watcher__ (e.g. `searchQuery: newValue => this.updateAutocomplete(newValue)`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.updateAutocomplete` will be undefined.</p>
@@ -720,7 +720,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
720
720
-**另见:**
721
721
-[`Vue.filter`](#Vue-filter)
722
722
723
-
### 组件
723
+
### components
724
724
725
725
-**类型:**`Object`
726
726
@@ -731,29 +731,29 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
731
731
-**另见:**
732
732
-[组件](/guide/components.html)
733
733
734
-
## Options / Misc
734
+
## 选项 / 杂项
735
735
736
736
### parent
737
737
738
-
-**Type:**`Vue instance`
738
+
-**类型:**`Vue instance`
739
739
740
-
-**Details:**
740
+
-**详细:**
741
741
742
742
Specify the parent instance for the instance to be created. Establishes a parent-child relationship between the two. The parent will be accessible as `this.$parent` for the child, and the child will be pushed into the parent's `$children` array.
743
743
744
744
<pclass="tip">Use `$parent` and `$children` sparringly - they mostly serve as an escape-hatch. Prefer using props and events for parent-child communication.</p>
745
745
746
746
### mixins
747
747
748
-
-**Type:**`Array<Object>`
748
+
-**类型:**`Array<Object>`
749
749
750
-
-**Details:**
750
+
-**详细:**
751
751
752
752
The `mixins` option accepts an array of mixin objects. These mixin objects can contain instance options just like normal instance objects, and they will be merged against the eventual options using the same option merging logic in `Vue.extend()`. e.g. If your mixin contains a created hook and the component itself also has one, both functions will be called.
753
753
754
754
Mixin hooks are called in the order they are provided, and called before the component's own hooks.
755
755
756
-
-**Example:**
756
+
-**示例:**
757
757
758
758
```js
759
759
var mixin = {
@@ -767,31 +767,31 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
767
767
// -> 2
768
768
```
769
769
770
-
-**See also:**[Mixins](/guide/mixins.html)
770
+
-**另见:**[混合](/guide/mixins.html)
771
771
772
772
### name
773
773
774
-
-**Type:**`string`
774
+
-**类型:**`string`
775
775
776
-
-**Restriction:** only respected when used as a component option.
776
+
-**限制:** only respected when used as a component option.
777
777
778
-
-**Details:**
778
+
-**详细:**
779
779
780
780
Allow the component to recursively invoke itself in its template. Note that when a component is registered globally with `Vue.component()`, the global ID is automatically set as its name.
781
781
782
782
Another benefit of specifying a `name` option is debugging. Named components result in more helpful warning messages. Also, when inspecting an app in the [vue-devtools](https://github.com/vuejs/vue-devtools), unnamed components will show up as `<AnonymousComponent>`, which isn't very informative. By providing the `name` option, you will get a much more informative component tree.
783
783
784
784
### extends
785
785
786
-
-**Type:**`Object | Function`
786
+
-**类型:**`Object | Function`
787
787
788
-
-**Details:**
788
+
-**详细:**
789
789
790
790
Allows declaratively extending another component (could be either a plain options object or a constructor) without having to use `Vue.extend`. This is primarily intended to make it easier to extend between single file components.
791
791
792
792
This is similar to `mixins`, the difference being that the component's own options takes higher priority than the source component being extended.
793
793
794
-
-**Example:**
794
+
-**示例:**
795
795
796
796
```js
797
797
var CompA = { ... }
@@ -805,15 +805,15 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
805
805
806
806
### delimiters
807
807
808
-
-**Type:**`Array<string>`
808
+
-**类型:**`Array<string>`
809
809
810
-
-**default:**`["{{", "}}"]`
810
+
-**默认值:**`["{{", "}}"]`
811
811
812
-
-**Details:**
812
+
-**详细:**
813
813
814
814
Change the plain text interpolation delimiters. **This option is only available in the standalone build.**
815
815
816
-
-**Example:**
816
+
-**示例:**
817
817
818
818
```js
819
819
newVue({
@@ -825,13 +825,13 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
825
825
826
826
### functional
827
827
828
-
-**Type:**`boolean`
828
+
-**类型:**`boolean`
829
829
830
-
-**Details:**
830
+
-**详细:**
831
831
832
832
Causes a component to be stateless (no `data`) and instanceless (no `this` context). They are simply a `render` function that returns virtual nodes making them much cheaper to render.
0 commit comments