Skip to content

Commit 8caffa9

Browse files
authored
Merge pull request #9 from vuefe/2.0-cn
update
2 parents 115a98d + c6fa653 commit 8caffa9

File tree

11 files changed

+142
-226
lines changed

11 files changed

+142
-226
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ subtitle:
88
description: "Reactive Components for Modern Web Interfaces"
99
author: Evan You
1010
email:
11-
language:
11+
language: zh-CN
1212

1313
# URL
1414
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'

src/api/index.md

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -741,19 +741,18 @@ type: api
741741

742742
- **详细:**
743743

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.
744+
指定实例的父实例,在两者之间建立父子关系。子实例可以用 `this.$parent` 访问父实例,子实例被推入父实例的 `$children` 数组中。
745745

746-
<p class="tip">Use `$parent` and `$children` sparringly - they mostly serve as an escape-hatch. Prefer using props and events for parent-child communication.</p>
746+
<p class="tip">同时使用 `$parent` `$children` 有冲突 - 他们作为同一个入口 。更推荐用 props events 实现父子组件通信</p>
747747

748748
### mixins
749749

750750
- **类型:** `Array<Object>`
751751

752752
- **详细:**
753-
754-
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.
753+
754+
`mixins` 选项接受一个数组作为混合对象。这些混合实例对象可以像正常的实例对象一样包含选项,他们将在 `Vue.extend()` 里最终选择使用相同的选项合并逻辑合并。如:如果你混合包含一个钩子而创建组件本身也有一个,两个函数将被调用。
755+
Mixin钩子提供他们被调用的顺序,在调用组件的自己的钩子之前被调用。
757756

758757
- **示例:**
759758

@@ -775,30 +774,31 @@ type: api
775774

776775
- **类型:** `string`
777776

778-
- **限制:** only respected when used as a component option.
777+
- **限制:** 只有作为组件选项时起作用。
779778

780779
- **详细:**
781780

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
782+
783+
指定一个 `name` 选项的另一个好处是便于调试。被命名的组件有更友好的警告信息。另外,当在有 [vue-devtools](https://github.com/vuejs/vue-devtools), 未命名组件将显示成 `<AnonymousComponent>`, 这很没有语义。通过提供 `name` 选项,可以获得更有语义信息的组件树。
785784

786785
### extends
787786

788787
- **类型:** `Object | Function`
789788

790789
- **详细:**
791790

792-
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+
792+
允许声明扩展另一个组件(可以是一个简单的选择对象或构造函数),而无需使用 `Vue.extend`。这主要是为了便于扩展单文件组件。
793793

794-
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` 类似,区别在于,组件的选项需要比源组件被扩展有更高的优先级。
795795

796796
- **示例:**
797797

798798
``` js
799799
var CompA = { ... }
800800

801-
// extend CompA without having to call Vue.extend on either
801+
// 在没有调用 Vue.extend 时候继承 CompA
802802
var CompB = {
803803
extends: CompA,
804804
...
@@ -813,7 +813,8 @@ type: api
813813

814814
- **详细:**
815815

816-
Change the plain text interpolation delimiters. **This option is only available in the standalone build.**
816+
改变纯文本插入分隔符。 **这个选择只有在独立构建时才有用。**
817+
817818

818819
- **示例:**
819820

@@ -822,7 +823,7 @@ type: api
822823
delimiters: ['${', '}']
823824
})
824825

825-
// Delimiters changed to ES6 template string style
826+
// Delimiters ES6 模板转换成字符串样式
826827
```
827828

828829
### functional
@@ -831,9 +832,9 @@ type: api
831832

832833
- **详细:**
833834

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.
835+
使组件无状态(没有 `data` )和无实例(没有 `this` 上下文)。他们用一个简单的 `render` 函数返回虚拟节点使他们更容易渲染。
835836

836-
- **另见:** [Functional Components](/guide/render-function.html#Functional-Components)
837+
- **另见:** [函数式组件](/guide/render-function.html#Functional-Components)
837838

838839
## 实例属性
839840

@@ -972,70 +973,70 @@ type: api
972973

973974
### vm.$isServer
974975

975-
- **类型:** `boolean`
976+
- **类型** `boolean`
976977

977978
- **只读**
978979

979-
- **详细:**
980+
- **详细**
980981

981982
当前 Vue 实例是否运行于服务器。
982983

983-
- **另见:** [服务端渲染](/guide/ssr.html)
984+
- **另见** [服务端渲染](/guide/ssr.html)
984985

985-
## Instance Methods / Data
986+
## 实例方法 / 数据
986987

987988
<h3 id="vm-watch">vm.$watch( expOrFn, callback, [options] )</h3>
988989

989-
- **Arguments:**
990+
- **参数:**
990991
- `{string | Function} expOrFn`
991992
- `{Function} callback`
992993
- `{Object} [options]`
993994
- `{boolean} deep`
994995
- `{boolean} immediate`
995996

996-
- **Returns:** `{Function} unwatch`
997+
- **返回值:** `{Function} unwatch`
997998

998-
- **Usage:**
999+
- **用法:**
9991000

1000-
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.
1001+
观察 Vue 实例的一个表达式或计算函数。回调的参数为新值和旧值。表达式可以是某个键路径或任意合法绑定表达式。
10011002

1002-
<p class="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>
1003+
<p class="tip">注意:在修改(不是替换)对象或数组时,旧值将与新值相同,因为它们索引同一个对象/数组。Vue 不会保留修改之前值的副本。</p>
10031004

1004-
- **Example:**
1005+
- **示例:**
10051006

10061007
``` js
1007-
// keypath
1008+
// 键路径
10081009
vm.$watch('a.b.c', function (newVal, oldVal) {
1009-
// do something
1010+
// 做点什么
10101011
})
10111012

1012-
// expression
1013+
// 表达式
10131014
vm.$watch('a + b', function (newVal, oldVal) {
1014-
// do something
1015+
// 做点什么
10151016
})
10161017

1017-
// function
1018+
// 函数
10181019
vm.$watch(
10191020
function () {
10201021
return this.a + this.b
10211022
},
10221023
function (newVal, oldVal) {
1023-
// do something
1024+
// 做点什么
10241025
}
10251026
)
10261027
```
10271028

1028-
`vm.$watch` returns an unwatch function that stops firing the callback:
1029+
`vm.$watch` 返回一个取消观察函数,用来停止触发回调:
10291030

10301031
``` js
10311032
var unwatch = vm.$watch('a', cb)
1032-
// later, teardown the watcher
1033+
// 之后取消观察
10331034
unwatch()
10341035
```
10351036

1036-
- **Option: deep**
1037+
- **选项:deep**
10371038

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.
1039+
为了发现对象内部值的变化,可以在选项参数中指定 `deep: true` 。注意监听数组的变动不需要这么做。
10391040

10401041
``` js
10411042
vm.$watch('someObject', callback, {
@@ -1045,43 +1046,43 @@ type: api
10451046
// callback is fired
10461047
```
10471048

1048-
- **Option: immediate**
1049+
- **选项:immediate**
10491050

1050-
Passing in `immediate: true` in the option will trigger the callback immediately with the current value of the expression:
1051+
在选项参数中指定 `immediate: true` 将立即以表达式的当前值触发回调:
10511052

10521053
``` js
10531054
vm.$watch('a', callback, {
10541055
immediate: true
10551056
})
1056-
// callback is fired immediately with current value of `a`
1057+
// 立即以 `a` 的当前值触发回调
10571058
```
10581059

10591060
<h3 id="vm-set">vm.$set( object, key, value )</h3>
10601061

1061-
- **Arguments:**
1062+
- **参数:**
10621063
- `{Object} object`
10631064
- `{string} key`
10641065
- `{any} value`
10651066

1066-
- **Returns:** the set value.
1067+
- **返回值:** 设置的值.
10671068

1068-
- **Usage:**
1069+
- **用法:**
10691070

1070-
This is the **alias** of the global `Vue.set`.
1071+
这是全局 `Vue.set`**别名**
10711072

1072-
- **See also:** [Vue.set](#Vue-set)
1073+
- **另见:** [Vue.set](#Vue-set)
10731074

10741075
<h3 id="vm-delete">vm.$delete( object, key )</h3>
10751076

1076-
- **Arguments:**
1077+
- **参数:**
10771078
- `{Object} object`
10781079
- `{string} key`
10791080

1080-
- **Usage:**
1081+
- **用法:**
10811082

1082-
This is the **alias** of the global `Vue.delete`.
1083+
这是全局 `Vue.delete`**别名**
10831084

1084-
- **See also:** [Vue.delete](#Vue-delete)
1085+
- **另见:** [Vue.delete](#Vue-delete)
10851086

10861087
## 实例方法/事件
10871088

@@ -1151,9 +1152,9 @@ type: api
11511152

11521153
- **用法:**
11531154

1154-
如果 Vue 实例在实例化时没有收到 el 选项,则它处于“未挂载”状态,没有关联的 DOM 元素或片断。可以使用 vm.$mount() 手动地挂载一个未挂载的实例。
1155+
如果 Vue 实例在实例化时没有收到 el 选项,则它处于“未挂载”状态,没有关联的 DOM 元素或片断。可以使用 `vm.$mount()` 手动地挂载一个未挂载的实例。
11551156

1156-
如果没有"elementOrSelector"参数,模板将被渲染为文档之外的的元素,并且你必须使用原生DOM API把它插入文档中。
1157+
如果没有 `elementOrSelector` 参数,模板将被渲染为文档之外的的元素,并且你必须使用原生DOM API把它插入文档中。
11571158

11581159
这个方法返回实例自身,因而可以链式调用其它实例方法。
11591160

@@ -1225,31 +1226,31 @@ type: api
12251226

12261227
完全销毁一个实例。清理它与其它实例的连接,解绑它的全部指令及事件监听器。
12271228

1228-
"beforeDestroy"和"destroyed"之间触发。
1229+
`beforeDestroy``destroyed` 之间触发。
12291230

1230-
<p class="tip">在大多数场景中你不应该调用这个方法。最好使用"v-if"和"v-for"指令以数据驱动的方式控制子组件的生命周期。</p>
1231+
<p class="tip">在大多数场景中你不应该调用这个方法。最好使用 `v-if` 和 `v-for` 指令以数据驱动的方式控制子组件的生命周期。</p>
12311232

12321233
- **另见:** [生命周期图示](/guide/instance.html#Lifecycle-Diagram)
12331234

1234-
## Directives
1235+
## 指令
12351236

12361237
### v-text
12371238

1238-
- **Expects:** `string`
1239+
- **类型:** `string`
12391240

1240-
- **Details:**
1241+
- **详细:**
12411242

12421243
Updates the element's `textContent`. If you need to update the part of `textContent`, you should use `{% raw %}{{ Mustache }}{% endraw %}` interpolations.
12431244

1244-
- **Example:**
1245+
- **示例:**
12451246

12461247
```html
12471248
<span v-text="msg"></span>
12481249
<!-- same as -->
12491250
<span>{{msg}}</span>
12501251
```
12511252

1252-
- **See also:** [Data Binding Syntax - interpolations](/guide/syntax.html#Text)
1253+
- **另见:** [Data Binding Syntax - interpolations](/guide/syntax.html#Text)
12531254

12541255
### v-html
12551256

src/guide/comparison.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Vue 和 React 也提供提供功能性组件,这些组件都是没有声明,
9393

9494
显然,在生产中的性能是最重要的,并且也是到目前为止我们所讨论的。开发过程中的表现也是很重要的。好消息是用 Vue 和 React 开发大多数应用的速度都是足够快的。
9595

96-
然而,加入你要开发一个对性能要求比较高的数据可视化或者动画的应用时,这将会很有用。在开发中, Vue 每秒最高处理10帧,而 React 每秒最高处理不到1帧。
96+
然而,假如你要开发一个对性能要求比较高的数据可视化或者动画的应用时,这将会很有用。在开发中, Vue 每秒最高处理10帧,而 React 每秒最高处理不到1帧。
9797

9898
这是由于 React 有大量的检查机制,这能让它提供许多有用的警告和错误提示信息。我们同意那些很重要的,但在我们实现这些检查时候,也更加密切地关注着性能。
9999

@@ -223,7 +223,7 @@ Vue样扩大后就像React,缩小后就像 Jquery。你需要做的就是把
223223
### 本地渲染
224224

225225

226-
ReactNative能使你用相同的组件模型编写有本地渲染能力的APP(IOS或Android)。能同时跨多平台开发,对开发者是非常棒的。相应地,Vue和Weex会进行官方合作,Weex是阿里的跨平台用户界面开发框架,Weex 的 JavaScript 框架运行时用的就是Vue。这以为着不仅在浏览器,在 IOS 和 Android 上面也可以用 Vue 来进行开发
226+
ReactNative能使你用相同的组件模型编写有本地渲染能力的APP(IOS或Android)。能同时跨多平台开发,对开发者是非常棒的。相应地,Vue和Weex会进行官方合作,Weex是阿里的跨平台用户界面开发框架,Weex 的 JavaScript 框架运行时用的就是Vue。这意味着在借助Weex的情况下,你使用Vue语法开发的组件不仅仅可以运行在浏览器端,还能被用于开发 IOS 和 Android 上的原生应用
227227

228228
在现在,Weex 还在积极发展,成熟度也不能和 ReactNative 相抗衡。但是,Weex的发展是由世界上最大的电子商务企业的需求在驱动,Vue 团队也会和 Weex 团队积极合作确保为开发者带来良好的开发体验。
229229

@@ -233,7 +233,7 @@ Mobx 在 React 社区很流行,实际上在Vue也采用了几乎相同的反
233233

234234
## Angular 1
235235

236-
Due的一些语法和Angular的很相似(例如 `v-if` vs `ng-if`)。因为Angular是Vue早期开发的灵感来源。然而,Augular中存在许多问题,在Vue中已经得到解决。
236+
Vue的一些语法和Angular的很相似(例如 `v-if` vs `ng-if`)。因为Angular是Vue早期开发的灵感来源。然而,Augular中存在许多问题,在Vue中已经得到解决。
237237

238238
### 复杂性
239239

0 commit comments

Comments
 (0)