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
+59-58Lines changed: 59 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -741,19 +741,18 @@ type: api
741
741
742
742
-**详细:**
743
743
744
-
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.
<pclass="tip">Use `$parent` and `$children` sparringly - they mostly serve as an escape-hatch. Prefer using props and events for parent-child communication.</p>
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.
755
-
756
-
Mixin hooks are called in the order they are provided, and called before the component's own hooks.
-**限制:**only respected when used as a component option.
777
+
-**限制:**只有作为组件选项时起作用。
779
778
780
779
-**详细:**
781
780
782
-
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.
783
-
784
-
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.
781
+
允许组件模板递归地调用自身。注意,组件在全局用 `Vue.component()` 注册时,全局 ID 自动作为组件的 name。
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.
This is similar to `mixins`, the difference being that the component's own options takes higher priority than the source component being extended.
794
+
这和 `mixins` 类似,区别在于,组件的选项需要比源组件被扩展有更高的优先级。
795
795
796
796
-**示例:**
797
797
798
798
```js
799
799
var CompA = { ... }
800
800
801
-
//extend CompA without having to call Vue.extend on either
801
+
//在没有调用 Vue.extend 时候继承 CompA
802
802
var CompB = {
803
803
extends: CompA,
804
804
...
@@ -813,7 +813,8 @@ type: api
813
813
814
814
-**详细:**
815
815
816
-
Change the plain text interpolation delimiters. **This option is only available in the standalone build.**
816
+
改变纯文本插入分隔符。 **这个选择只有在独立构建时才有用。**
817
+
817
818
818
819
-**示例:**
819
820
@@ -822,7 +823,7 @@ type: api
822
823
delimiters: ['${', '}']
823
824
})
824
825
825
-
// Delimiters changed to ES6 template string style
826
+
// Delimiters 将 ES6 模板转换成字符串样式
826
827
```
827
828
828
829
### functional
@@ -831,9 +832,9 @@ type: api
831
832
832
833
-**详细:**
833
834
834
-
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.
Watch an expression or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value. The expression can be a single keypath or any valid binding expressions.
<pclass="tip">Note: when mutating (rather than replacing) an Object or an Array, the old value will be the same as new value because they reference the same Object/Array. Vue doesn't keep a copy of the pre-mutate value.</p>
`vm.$watch`returns an unwatch function that stops firing the callback:
1029
+
`vm.$watch`返回一个取消观察函数,用来停止触发回调:
1029
1030
1030
1031
```js
1031
1032
var unwatch =vm.$watch('a', cb)
1032
-
//later, teardown the watcher
1033
+
//之后取消观察
1033
1034
unwatch()
1034
1035
```
1035
1036
1036
-
-**Option: deep**
1037
+
-**选项:deep**
1037
1038
1038
-
To also detect nested value changes inside Objects, you need to pass in `deep: true`in the options argument. Note that you don't need to do so to listen for Array mutations.
Updates the element's `textContent`. If you need to update the part of `textContent`, you should use `{% raw %}{{ Mustache }}{% endraw %}` interpolations.
0 commit comments