debug mode is not available in the minified production builds.
+
@@ -153,15 +152,15 @@ Will result in:
- **callback** `Function`
-Vue.js batches view updates and executes them all asynchronously. It uses `requestAnimationFrame` if available and falls back to `setTimeout(fn, 0)`. This method calls the callback after the next view update, which can be useful when you want to wait until the view has been updated.
+Vue.js 批量处理视图更新并对其异步执行。如果可用的话它会使用 `requestAnimationFrame` 并返回到 `setTimeout(fn, 0)`。这个方法在下一个视图更新后调用回调,当你想一直等待到该视图被更新了,用这个方法会很好。
### Vue.use( plugin, [args...] )
- **plugin** `Object` or `Function`
-- **args...** *optional*
+- **args...** *可选的*
-Mount a Vue.js plugin. If the plugin is an Object, it must have an `install` method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument. For more details, see [Plugins](/guide/extending.html#Extend_with_Plugins).
+挂载一个 Vue.js 的插件。如果该插件是一个对象,它必须有一个 `install` 的方法。如果它本身就是一个方法,它必须被作为安装方法来对待。安装方法将会被 Vue 作为一个参数来调用。更多详情请阅[插件](../guide/extending.html#使用插件进行扩展)。
### Vue.util
-Exposes the internal `util` module, which contains a number of utility methods. This is intended for advanced plugin/directive authoring, so you will need to look at the source code to see what's available.
\ No newline at end of file
+公开内部的 `util` 模块。该模块包含一些列实用方法(utility methods)。这是被为用来编写高级插件/指令,因此你必须查看源码来确定哪些是可操作的。
diff --git a/source/api/index.md b/source/api/index.md
index f908cbd499..ccd26356e1 100644
--- a/source/api/index.md
+++ b/source/api/index.md
@@ -1,24 +1,24 @@
-title: "The Vue Constructor"
+title: "Vue 构造函数"
type: api
order: 1
---
-The `Vue` constructor is the core of Vue.js. It is a constructor function that allows you to create Vue instances. Creating a Vue instance is straightforward:
+`Vue`的构造函数是Vue.js的核心。它允许你创建Vue实例。创建一个Vue实例非常简单明了:
``` js
var vm = new Vue({ /* options */ })
```
-When you instantiate a Vue instance, you need to pass in an option object which can include information about the DOM element, data object, mixin methods, lifecycle callbacks and more. See the full list of [Instantiation Options](/api/options.html).
+当你初始化一个Vue实例,你需要传递一个包括DOM对象,data对象,mixin方法,生命周期回调函数等内容的option对象。完整列表见[初始化参数](../api/options.html)。
-Each Vue instance is essentially a ViewModel (hence the variable name `vm` you will see throughout the docs). It has an associated DOM element `$el`, which is roughly the V in MVVM. It also has an associated JavaScript object `$data`, which corresponds to the M in MVVM. Changing the M results in updates in the V. For two-way bindings, user inputs triggered in the V results in changes in the M. For more details check out [Instance Properties](/api/instance-properties.html).
+每个Vue实例本质上就是一个ViewModel (因此在本文档中你会看到好多变量名叫`vm`)。每个实例都有一个DOM对象属性叫`$el`,它大致相当于MVVM中的V。每个实例也有一个JavaScript对象属性叫`$data`,相对应的就是MVVM中的M。改变M会触发V的更新。对于双向绑定,用户对V的介入会触发M中的变化。详细请看[实例属性](../api/instance-properties.html)。
-If you provided the `el` option at instantiation, the Vue instance will immediately enter the compilation phase. Otherwise, it will wait until `vm.$mount()` is called before it starts compilation. During the compilation phase, Vue walks through the DOM and collects the directives it runs into, and "links" the data and the DOM with these directives. Once linked, these DOM nodes are now said to be managed by the Vue instance. A DOM node can only be managed by one Vue instance, and should not be compiled more than once.
+初始化的时候,如果你提供了`el`,那么这个实例就会直接进入编译阶段(compilation phase)。否则只有执行了`vm.$mount()`才会开始编译。在编译过程,Vue会走遍DOM树来收集遇到的指令(directives),然后通过这些指令建立数据和DOM的关系。一旦完成,就可以说现在这些DOM节点是被Vue实例来管理了。一个DOM节点只能被一个Vue实例管理,而且不会被2次编译。
-Vue instances proxy access to their `$data` objects, so if you have `vm.$data.msg` you can also access it as `vm.msg`. This might look a bit magical, but is totally optional. You can stick to `vm.$data.msg` for more explicit data access. However it is still important to notice the difference between `vm` and `vm.$data`, since the former cannot be observed by other Vue instances as data.
+Vue实例通过代理方法访问他们的`$data`对象,如果你有个变量叫msg,你可以通过`vm.$data.msg`访问也可以通过`vm.msg`来访问。看起来有点神奇,但这完全是可选的。你完全可以就用`vm.$data.msg` 这种方式来访问。但不管怎样,我们仍需要注意到`vm`和`vm.$data`的区别,因为前者是不能作为数据对象被别的Vue实例监视的。
-It's also worth noting that data objects do not necessarily belong to a single Vue instance - multiple ViewModels can observe the same piece of data, whether directly as `$data` or nested under it. This is useful when multiple components need to react to a shared global state object.
+还有一点值得注意的是数据对象(data objects)并不只属于一个Vue实例,多个ViewModel可以监视同一个数据对象,不论是`$data`本身还是它的属性。当多个组件需要共享一个全局状态数据对象的时候,这个特性就非常有用。
-Each Vue instance also has a number of [Instance Methods](/api/instance-methods.html) which cover data observation, event communication and DOM manipulation.
+每个Vue实例也有不少[实例方法](../api/instance-methods.html),包括数据监视,事件通讯和DOM操作。
-Finally, the `Vue` constructor itself also exposes the [Global API](/api/global-api.html), which allow you to extend the `Vue` class, configure global settings and register global custom assets such as components, directives, filters and more.
+最后,`Vue`的构造函数本身还有几个[全局API](../api/global-api.html),能够让你扩展`Vue`的类,配置全局属性以及注册全局自定义组件,像components,directives,filters等等。
\ No newline at end of file
diff --git a/source/api/instance-methods.md b/source/api/instance-methods.md
index f8474dced4..01c02b139d 100644
--- a/source/api/instance-methods.md
+++ b/source/api/instance-methods.md
@@ -1,11 +1,11 @@
-title: Instance Methods
+title: 实例方法
type: api
order: 4
---
## Data
-> You can observe data changes on a Vue instance. Note that all watch callbacks fire asynchronously. In addition, value changes are batched within an event loop. This means when a value changes multiple times within a single event loop, the callback will be fired only once with the latest value.
+> 你可以在Vue运行实例中监视数据的变化。你会注意到所有的watch回调都是异步发生的。而且,结果是在事件循环中被分批处理的。这就意味着一个结果假设在一次事件循环中改变多次,回调只会发生一次并直接变到最后的结果。
### vm.$watch( expression, callback, [deep, immediate] )
@@ -14,7 +14,7 @@ order: 4
- **deep** `Boolean` *optional*
- **immdediate** `Boolean` *optional*
-Watch an expression on the Vue instance for changes. The expression can be a single keypath or actual expressions:
+监听在Vue实例中改变的一个表达式。表达式可以是一个单独的路径或者是一个实际的表达式:
``` js
vm.$watch('a + b', function (newVal, oldVal) {
@@ -22,26 +22,28 @@ vm.$watch('a + b', function (newVal, oldVal) {
})
```
-To also detect nested value changes inside Objects, you need to pass in `true` for the third `deep` argument. Note that you don't need to do so to listen for Array mutations.
+也可以监视在对象中的属性,你需要为 `deep` 传递一个 `true` 来使用此功能 。
+
+请注意你不可以这么监视用来数组中元素的变化。
``` js
vm.$watch('someObject', callback, true)
vm.someObject.nestedValue = 123
-// callback is fired
+// 回调被触发
```
-Passing in `true` for the fourth `immediate` argument will trigger the callback immediately with the current value of the expression:
+如果传递一个 `true` 到第四个变量 `immediate` , 那么回调会带着现在表达式的结果被立即触发。
``` js
vm.$watch('a', callback, false, true)
-// callback is fired immediately with current value of `a`
+// 回调使用现在表达式的结果 `a` 被立刻触发
```
-Finally, `vm.$watch` returns an unwatch function that stops firing the callback:
+最后,还需要使用 `vm.$watch` 来返回一个停止监视的函数用来停止继续触发回调。
``` js
var unwatch = vm.$watch('a', cb)
-// later, teardown the watcher
+// 最后,停止监制
unwatch()
```
@@ -49,33 +51,33 @@ unwatch()
- **expression** `String`
-Retrieve a value from the Vue instance given an expression. Expressions that throw errors will be suppressed and return `undefined`.
+为 Vue 实例传递一个表达式来获得结果,如果这个表达式带有错误,那么错误不会被报告并且返回一个 `undefined` 。
### vm.$set( keypath, value )
- **keypath** `String`
- **value** `*`
-Set a data value on the Vue instance given a valid keypath. If the path doesn't exist it will be created.
+通过给 Vue 实例传递一个可用的路径来设置结果,如果路径不存在那么会被创建。
### vm.$add( keypath, value )
- **keypath** `String`
- **value** `*`
-Add a root level property to the Vue instance (and also its `$data`). Due to the limitations of ES5, Vue cannot detect properties directly added to or deleted from an Object, so use this method and `vm.$delete` when you need to do so. Additionally, all observed objects are augmented with these two methods too.
+添加一个根等级(root level property)的属性到 Vue 实例(或者也可以说是它自己的 `$data`)。由于 ES5 的限制,Vue 不可以直接监视对象中属性的增加或者删除,所以当你需要做这些的时候请使用这个方法和 `vm.$delete`。另外,所以被监视的对象也都由这两个方法增大。
### vm.$delete( keypath )
- **keypath** `String`
-Delete a root level property on the Vue instance (and also its `$data`).
+在 Vue 实例中删除一个根等级属性(或者是它的 `$data`)。
### vm.$eval( expression )
- **expression** `String`
-Evaluate an expression that can also contain filters.
+求一个表达式的值,它可以包含数个筛选器。
``` js
// assuming vm.msg = 'hello'
@@ -88,6 +90,7 @@ vm.$eval('msg | uppercase') // -> 'HELLO'
Evaluate a piece of template string containing mustache interpolations. Note that this method simply performs string interpolation; attribute directives are not compiled.
+
``` js
// assuming vm.msg = 'hello'
vm.$interpolate('{{msg}} world!') // -> 'hello world!'
@@ -97,7 +100,7 @@ vm.$interpolate('{{msg}} world!') // -> 'hello world!'
- **keypath** `String` *optional*
-Log the current instance data as a plain object, which is more console-inspectable than a bunch of getter/setters. Also accepts an optional key.
+记录当前的实例数据保存在一个空白的对象,这种是比很多取值方法/设值方法都更有可检查性(console-inspectable)。当然也可以传递一个路径(可选)进去。
``` js
vm.$log() // logs entire ViewModel data
@@ -106,80 +109,80 @@ vm.$log('item') // logs vm.item
## Events
-> Each vm is also an event emitter. When you have multiple nested ViewModels, you can use the event system to communicate between them.
+> 每个 vm 都是一个事件的emitter。当你有很多的视图模型时,你可以用这种事件系统去在他们之间沟通数据。
### vm.$dispatch( event, [args...] )
- **event** `String`
- **args...** *optional*
-Dispatch an event from the current vm that propagates all the way up to its `$root`. If a callback returns `false`, it will stop the propagation at its owner instance.
+从当前的 vm 处理一个事件,这个 vm 一直传播到它的 `$root` 。如果其中一个回调返回了 `false` ,那么在它自己的实例中停止传播。
### vm.$broadcast( event, [args...] )
- **event** `String`
- **args...** *optional*
-Emit an event to all children vms of the current vm, which gets further broadcasted to their children all the way down. If a callback returns `false`, its owner instance will not broadcast the event any further.
+为当前 vm 的所有子 vm 注册该事件,这个 vm 会一直传播到到他的子vm。当一个回调返回 `false` 。当一个回调返回了 `false`,那么它的所有者实例就不会广播这个事件了。
### vm.$emit( event, [args...] )
- **event** `String`
- **args...** *optional*
-Trigger an event on this vm only.
+只在这个 vm 里面触发被传递的事件。
### vm.$on( event, callback )
- **event** `String`
- **callback** `Function`
-Listen for an event on the current vm.
+在当前 vm 中监听事件。
### vm.$once( event, callback )
- **event** `String`
- **callback** `Function`
-Attach a one-time only listener for an event.
+为一个事件注册一个一次性的监听器。
### vm.$off( [event, callback] )
- **event** `String` *optional*
- **callback** `Function` *optional*
-If no arguments are given, stop listening for all events; if only the event is given, remove all callbacks for that event; if both event and callback are given, remove that specific callback only.
+如果没有传递变量,那么停止监视所有时间;如果传递了一个事件,那么移除该事件的所有回调;如果事件和回调都被传递,则只移除该回调。
## DOM
-> All vm DOM manipulation methods work like their jQuery counterparts - except they also trigger Vue.js transitions if there are any declared on vm's `$el`. For more details on transitions see [Adding Transition Effects](/guide/transitions.html).
+> 所有 vm 的操作 DOM 的方法都是类似于jQuery中相同功能一样 - 除了被声明为 vm 的 `$el` 会触发 Vue.js 的转换。对于转化的更多细节可以看 [Adding Transition Effects](../guide/transitions.html) 。
### vm.$appendTo( element|selector, [callback] )
- **element** `HTMLElement` | **selector** `String`
- **callback** `Function` *optional*
-Append the vm's `$el` to target element. The argument can be either an element or a querySelector string.
+在目标元素后面添加 vm 的 `$el` ,变量可以是一个元素或者是一个被选择器选中的字符串。
### vm.$before( element|selector, [callback] )
- **element** `HTMLElement` | **selector** `String`
- **callback** `Function` *optional*
-Insert the vm's `$el` before target element.
+在目标元素之前插入 vm 的 `$el` 。
### vm.$after( element|selector, [callback] )
- **element** `HTMLElement` | **selector** `String`
- **callback** `Function` *optional*
-Insert the vm's `$el` after target element.
+在目标元素之后插入 vm 的 `$el` 。
### vm.$remove( [callback] )
- **callback** `Function` *optional*
-Remove the vm's `$el` from the DOM.
+从 DOM 中移除 vm 的 `$el` 。
## Lifecycle
@@ -187,29 +190,30 @@ Remove the vm's `$el` from the DOM.
- **element** `HTMLElement` | **selector** `String` *optional*
-If the Vue instance didn't get an `el` option at instantiation, you can manually call `$mount()` to assign an element to it and start the compilation. If no argument is provided, an empty `
` will be automatically created. Calling `$mount()` on an already mounted instance will have no effect. The method returns the instance itself so you can chain other instance methods after it.
+如果 Vue 实例在实例化的时候没有被传递一个 `el` 的选项,你可以自己调用 `$mount()` 赋一个元素给它并且开始编译。如果没有变量提供,就会自动生成一个空的 `
` 。在已经被挂在的实例上调用 `$mount()` 上是没有作用的。这个方法会返回实例本身所以如果你可以在它后面连锁一些其他的实例方法。
### vm.$destroy( [remove] )
- **remove** `Boolean` *optional*
-Completely destroy a vm. Clean up its connections with other existing vms, unbind all its directives and remove its `$el` from the DOM. Also, all `$on` and `$watch` listeners will be automatically removed.
+完全销毁一个 vm。清空它对其他存在的 vm 的连接,释放它的所有中间件并且从DOM中移除它的 `$el`。并且所有的 `$on` 和 `$watch` 监听器也都会被自动移除。
### vm.$compile( element )
- **element** `HTMLElement`
-Partially compile a piece of DOM (Element or DocumentFragment). The method returns a `decompile` function that tearsdown the directives created during the process. Note the decompile function does not remove the DOM. This method is exposed primarily for writing advanced custom directives.
+局部编译一个 DOM (元素或者是文档的片段)。这个方法返回一个 `decompile` 函数会关闭所有过程中已经被创建的中间件。请注意 decompile 函数不会移除DOM,这个方法对于写入高级自定义中间件来说根本上就是暴露的(exposed)。
+
### vm.$addChild( [options, constructor] )
- **options** `Object` *optional*
- **constructor** `Function` *optional*
-Adds a child instance to the current instance. The options object is the same in manually instantiating an instance. Optionally you can pass in a constructor created from `Vue.extend()`.
+为当前的实例增加一个子实例。选项对象和手动实例化一个实例是相同的。传递一个用 `Vue.extend()` 创造的构造器进去也是可以的。
-There are three implications of a parent-child relationship between instances:
+对于实例间父子关系有三种含义:
-1. The parent and child can communicate via [the event system](#Events).
-2. The child has access to all parent assets (e.g. custom directives).
-3. The child, if inheriting parent scope, has access to parent scope data properties.
\ No newline at end of file
+1. 父实例和子实例可以通过[the event system](#Events)来沟通
+2. 子实例有对父实例所有资源的许可。(例子: 自定义中间件)
+3. 如果是继承了父实例作用域的子实例,那么对父实例作用域的数据属性也有许可
\ No newline at end of file
diff --git a/source/api/instance-properties.md b/source/api/instance-properties.md
index 542b9f2be7..980d1defea 100644
--- a/source/api/instance-properties.md
+++ b/source/api/instance-properties.md
@@ -1,4 +1,4 @@
-title: Instance Properties
+title: 实例属性
type: api
order: 3
---
@@ -6,21 +6,21 @@ order: 3
### vm.$el
- **Type:** `HTMLElement`
-- **Read only**
+- **只读**
-The DOM element that the Vue instance is managing.
+返回Vue实例正在管理的Dom元素。
### vm.$data
- **Type:** `Object`
-The data object that the Vue instance is observing. You can swap it with a new object. The Vue instance proxies access to the properties on its data object.
+返回Vue实例正在监视的数据对象(data object)。当然你可以用新的对象去替换它。Vue实例通过代理方法访问他们的$data对象的属性。
### vm.$options
- **Type:** `Object`
-The instantiation options used for the current Vue instance. This is useful when you want to include custom properties in the options:
+返回当前Vue实例所使用的实例化选项。当你想要添加自定义的属性到实例化选项里面的时候,这个属性是很有用的:
``` js
new Vue({
@@ -34,31 +34,31 @@ new Vue({
### vm.$parent
- **Type:** `Vue`
-- **Read only**
+- **只读**
-The parent instance, if the current instance has one.
+如果当前Vue实例有父实例(parent instance),将返回父实例。
### vm.$root
- **Type:** `Vue`
-- **Read only**
+- **只读**
-The root Vue instance of the current component tree. If the current instance has no parents this value will be itself.
+返回当前Vue结构树(component tree)的根Vue实例。如果当前的 `vm` 已经没有父实例的话将会返回它自己。
### vm.$
- **Type:** `Object`
-- **Read only**
+- **只读**
-An object that holds child components that have `v-ref` registered. For more details see [v-ref](/api/directives.html#v-ref).
+返回一个对象,这个对象管理着有着 `v-ref` 指令的子组件。更多细节请查看 [v-ref](../api/directives.html#v-ref).
### vm.$$
- **Type:** `Object`
- **Read only**
-An object that holds DOM elements that have `v-el` registered. For more details see [v-el](/api/directives.html#v-el).
+返回一个对象,这个对象管理所有有着 `v-el` 指令的DOM元素。更多细节请查看 [v-el](../api/directives.html#v-el).
### Meta Properties
-Instances created by `v-repeat` will also have some meta properties, e.g. `vm.$index`, `vm.$key` and `vm.$value`. For more details, see [the guide on using `v-repeat`](/guide/list.html).
\ No newline at end of file
+被 `v-repeat` 创建出来的实例也会拥有一些元属性(Meta properties)。例如 `vm.$index`, `vm.$key` 和 `vm.$value` 等。更多细节请查看 [the guide on using `v-repeat`](../guide/list.html).
\ No newline at end of file
diff --git a/source/api/options.md b/source/api/options.md
index 773884dc27..3100c1c70b 100644
--- a/source/api/options.md
+++ b/source/api/options.md
@@ -1,4 +1,4 @@
-title: Options
+title: 选项
type: api
order: 2
---
@@ -125,7 +125,7 @@ Vue.component('param-demo', {
```
-Param attributes can also contain interpolation tags. The interpolation will be evaluated against the parent, and under the hood they will be compiled as [`v-with`](/api/directives.html#v-with), which means when the value of the interpolated expression changes, the component's corresponding property will also be updated:
+Param attributes can also contain interpolation tags. The interpolation will be evaluated against the parent, and under the hood they will be compiled as [`v-with`](../api/directives.html#v-with), which means when the value of the interpolated expression changes, the component's corresponding property will also be updated:
``` html
@@ -158,7 +158,7 @@ If the option is available at instantiation, the instance will immediately enter
- **Type:** `String`
-A string template to be inserted into `vm.$el`. Any existing markup inside `vm.$el` will be overwritten, unless [content insertion points](/guide/components.html#Content_Insertion) are present in the template. If the **replace** option is `true`, the template will replace `vm.$el` entirely.
+A string template to be inserted into `vm.$el`. Any existing markup inside `vm.$el` will be overwritten, unless [content insertion points](../guide/components.html#内容插入) are present in the template. If the **replace** option is `true`, the template will replace `vm.$el` entirely.
If it starts with `#` it will be used as a querySelector and use the selected element's innerHTML and the template string. This allows the use of the common `
-#### Passing Down Individual Properties
+#### 向下传递独立属性
-`v-with` can also be used with an argument in the form of `v-with="childProp: parentProp"`. This means passing down `parent[parentProp]` to the child as `child[childProp]`. Note this data inheritance is one-way: when `parentProp` changes, `childProp` will be updated accordingly, however not the other way around.
+`v-with` 也能以 `v-with="childProp: parentProp"` 的形式传入一个参数来使用。也就是把 `parent[parentProp]` 向下传递给子级,作为子级的属性 `child[childProp]`。要注意的是这种数据继承是单向的:当 `parentProp` 发生改变时,`childProp` 会相应更新,反之则不然。
-**Example:**
+**示例:**
``` html
```
@@ -145,7 +145,7 @@ new Vue({
})
```
-**Result:**
+**结果**
-#### Using `paramAttributes`
+#### 使用 `paramAttributes` 参数标识
-It is also possible to use the [`paramAttributes`](/api/options.html#paramAttributes) option, which compiles into `v-with`, to expose an interface that looks more like custom elements:
+同样可以通过 [`paramAttributes`](../api/options.html#paramAttributes) 选项(会被编译成 `v-with` )来暴露一个看起来更像自定义元素的接口。
``` html
@@ -182,17 +182,17 @@ new Vue({
components: {
'child-component': {
paramAttributes: ['child-msg'],
- // dashed attributes are camelized,
- // so 'child-msg' becomes 'this.childMsg'
+ // 连字符分隔的属性会被转成驼峰形式,
+ // 所以“child-msg”成了“this.childMsg”
template: '
{{childMsg}} '
}
}
})
```
-### Scope Inheritance
+### 作用域继承
-If you want, you can also use the `inherit: true` option for your child component to make it prototypally inherit all parent properties:
+如果有需要,你也可以使用 `inherit: true` 选项来让子组件通过原型链继承父级的全部属性:
``` js
var parent = new Vue({
@@ -200,8 +200,8 @@ var parent = new Vue({
a: 1
}
})
-// $addChild() is an instance method that allows you to
-// programatically create a child instance.
+// $addChild() 是一个实例方法,
+// 它允许你用代码创建子实例。
var child = parent.$addChild({
inherit: true,
data: {
@@ -214,7 +214,7 @@ parent.a = 3
console.log(child.a) // -> 3
```
-Note this comes with a caveat: because data properties on Vue instances are getter/setters, setting `child.a = 2` will change `parent.a` instead of creating a new property on the child shadowing the parent one:
+这里有一点需要注意:由于 Vue 示例上的数据属性都是 getter/setter,设置 `child.a = 2` 会直接改变 `parent.a` 的值,而非在子级创建一个新属性遮蔽父级中的属性:
``` js
child.a = 4
@@ -222,22 +222,22 @@ console.log(parent.a) // -> 4
console.log(child.hasOwnProperty('a')) // -> false
```
-### A Note on Scope
+### 作用域注意事项
-When a component is used in a parent template, e.g.:
+当组件被用在父模板中时,例如:
``` html
-
+
```
-The directives here (`v-show` and `v-on`) will be compiled in the parent's scope, so the value of `active` and `onClick` will be resolved against the parent. Any directives/interpolations inside the child's template will be compiled in the child's scope. This ensures a cleaner separation between parent and child components.
+这里的命令( `v-show` 和 `v-on` )会在父作用域编译,所以 `active` 和 `onClick` 的取值取决于父级。任何子模版中的命令和插值都会在子作用域中编译。这样使得上下级组件间更好地分离。
-This rule also applies to [content insertion](#Content_Insertion), as explained later in this guide.
+这条规则同样适用于 [内容插入](#内容插入),这一点会在下文中详述。
-## Component Lifecycle
+## 组件生命周期
-Every component, or Vue instance, has its own lifecycle: it will be created, compiled, attached or detached, and finally destroyed. At each of these key moments the instance will emit corresponding events, and when creating an instance or defining a component, we can pass in lifecycle hook functions to react to these events. For example:
+每一个组件,或者说 Vue 的实例,都有着自己的生命周期:它会被创建、编译、附加、分离,最终销毁。在这每一个关键点,实例都会触发相应的事件,而在创建实例或者定义组件时,我们可以传入生命周期钩子函数来响应这些事件。例如:
``` js
var MyComponent = Vue.extend({
@@ -247,11 +247,11 @@ var MyComponent = Vue.extend({
})
```
-Check out the API reference for a [full list of lifecycle hooks](/api/options.html#Lifecycle) that are availble.
+查阅 API 文档中可用的 [生命周期钩子函数完整列表](../api/options.html#Lifecycle)。
-## Dynamic Components
+## 动态组件
-You can dynamically switch between components by using Mustache tags inside the `v-component` direcitve, which can be used together with routers to achieve "page switching":
+你可以通过在 `v-component` 命令中使用 Mustache 标签的方式在组件间动态切换,还能与路由一起使用实现“页面切换”:
``` js
new Vue({
@@ -269,36 +269,36 @@ new Vue({
``` html
-
+
```
-If you want to keep the switched-out components alive so that you can preserve its state or avoid re-rendering, you can add a `keep-alive` directive param:
+如果希望被切换出去的组件保持存活,从而保留它的当前状态或者避免反复重新渲染,你可以加上 `keep-alive` 命令参数:
``` html
-
+
```
-### Transition Control
+### 过渡控制
-There are two additional attribute parameters that allows advanced control of how dynamic components should transition from one to another.
+有两个额外的属性能够支持对动态组件间的切换方式进行高级控制。
-#### `wait-for`
+#### `wait-for` 等待事件
-An event name to wait for on the incoming child component before switching it with the current component. This allows you to wait for asynchronous data to be loaded before triggering the transition to avoid unwanted flash of emptiness in between.
+等待即将进入的组件触发该事件后再用新组件替换当前组件。这就允许你等待数据异步加载完成后再触发过渡,避免切换过程中出现空白闪烁。
-**Example:**
+**示例:**
``` html
```
``` js
-// component definition
+// 组件定义
{
- // fetch data and fire the event asynchronously in the
- // compiled hook. Using jQuery just for example.
+ // 获取数据并在编译完成钩子函数中异步触发事件。
+ // 这里jQuery只是用作演示。
compiled: function () {
var self = this
$.ajax({
@@ -312,30 +312,30 @@ An event name to wait for on the incoming child component before switching it wi
}
```
-#### `transition-mode`
+#### `transition-mode` 过渡模式
-By default, the transitions for incoming and outgoing components happen simultaneously. This param allows you to configure two other modes:
+默认情况下,进入组件和退出组件的过渡是同时进行的。这个参数允许设置成另外两种模式:
-- `in-out`: New component transitions in first, current component transitions out after incoming transition has finished.
-- `out-in`: Current component transitions out first, new componnent transitions in after outgoing transition has finished.
+- `in-out`:先进后出;先执行新组件过渡,当前组件在新组件过渡结束后执行过渡并退出。
+- `out-in`:先出后进;当前组件首先执行过渡并退出,新组件在当前组件过渡结束后执行过渡并进入。
-**Example**
+**示例:**
``` html
-
+
```
-## List and Components
+## 列表与组件
-For an Array of Objects, you can combine `v-component` with `v-repeat`. In this case, for each Object in the Array, a child ViewModel will be created using that Object as data, and the specified component as the constructor.
+对于一个对象数组,你可以把 `v-component` 和 `v-repeat` 组合使用。这种场景下,对于数组中的每个对象,都以该对象为数据创建一个子 ViewModel,以指定组件作为构造函数。
``` html
```
@@ -358,7 +358,7 @@ var parent2 = new Vue({
})
```
-**Result:**
+**结果:**
-## Child Reference
+## 子组件引用
-Sometimes you might need to access nested child components in JavaScript. To enable that you have to assign a reference ID to the child component using `v-ref`. For example:
+某些情况下需要通过 JavaScript 访问嵌套的子组件。要实现这种操作,需要使用 `v-ref` 为子组件分配一个 ID。例如:
``` html
@@ -391,15 +391,15 @@ Sometimes you might need to access nested child components in JavaScript. To ena
``` js
var parent = new Vue({ el: '#parent' })
-// access child component
+// 访问子组件
var child = parent.$.profile
```
-When `v-ref` is used together with `v-repeat`, the value you get will be an Array containing the child components mirroring the data Array.
+当 `v-ref` 与 `v-repeat` 一同使用时,会获得一个与数据数组对应的子组件数组。
-## Event System
+## 事件系统
-Although you can directly access a ViewModels children and parent, it is more convenient to use the built-in event system for cross-component communication. It also makes your code less coupled and easier to maintain. Once a parent-child relationship is established, you can dispatch and trigger events using each ViewModel's [event instance methods](/api/instance-methods.html#Events).
+虽然你可以直接访问一个 ViewModel 的子级与父级,但是通过内建的事件系统进行跨组件通讯更为便捷。这还能使你的代码进一步解耦,变得更易于维护。一旦建立了上下级关系,就能使用 ViewModel 的 [事件示例方法](../api/instance-methods.html#Events) 来分发和触发事件。
``` js
var Child = Vue.extend({
@@ -444,15 +444,15 @@ var parent = new Vue({
})
-## Private Assets
+## 私有资源
-Sometimes a component needs to use assets such as directives, filters and its own child components, but might want to keep these assets encapsulated so the component itself can be reused elsewhere. You can do that using the private assets instantiation options. Private assets will only be accessible by the instances of the owner component and its child components.
+有时一个组件需要使用类似命令、过滤器和子组件这样的资源,但是又希望把这些资源封装起来以便自己在别处复用。这一点可以用私有资源实例化选项来实现。私有资源只能被拥有该资源的组件的实例及其子组件访问。
``` js
-// All 5 types of assets
+// 全部5种类型的资源
var MyComponent = Vue.extend({
directives: {
- // id : definition pairs same with the global methods
+ // “id : 定义”键值对,与处理全局方法的方式相同
'private-directive': function () {
// ...
}
@@ -472,7 +472,7 @@ var MyComponent = Vue.extend({
})
```
-Alternatively, you can add private assets to an existing Component constructor using a chaining API similar to the global asset registration methods:
+又或者,可以用与全局资源注册方法类似的链式 API 为现有组件构造方法添加私有资源:
``` js
MyComponent
@@ -482,24 +482,24 @@ MyComponent
// ...
```
-## Content Insertion
+## 内容插入
-When creating reusable components, we often need to access and reuse the original content in the hosting element, which are not part of the component (similar to the Angular concept of "transclusion".) Vue.js implements a content insertion mechanism that is compatible with the current Web Components spec draft, using the special `
` element to serve as insertion points for the original content.
+在创建可复用组件时,我们通常需要在宿主元素中访问和重用原始数据,而它们并非组件的一部分(类似 Angular 的“transclusion”概念)。 Vue.js 实现了一套内容插入机制,它和目前的 Web Components 规范草案兼容,使用特殊的 `` 元素作为原始内容的插入点。
-Note: "transcluded" contents are compiled in the parent component's scope.
+注意:“transcluded”内容在父组件的作用域中编译。
-### Single Insertion Point
+### 单插入点
-When there is only one `` tag with no attributes, the entire original content will be inserted at its position in the DOM and replaces it. Anything originally inside the `` tags is considered **fallback content**. Fallback content will only be displayed if the hosting element is empty and has no content to be inserted. For example:
+只有一个不带属性的 `` 标签时,整个原始内容都会被插入到它在 DOM 中的位置并把它替换掉。原来在 `` 标签内部的所有内容会被视为 **后备内容**。后备内容只有在宿主元素为空且没有要插入的内容时才会被显示。例如:
-Template for `my-component`:
+`my-component` 的模板:
``` html
This is my component!
This will only be displayed if no content is inserted
```
-Parent markup that uses the component:
+使用该组件的父标签:
``` html
@@ -508,7 +508,7 @@ Parent markup that uses the component:
```
-The rendered result will be:
+渲染结果如下:
``` html
@@ -518,11 +518,11 @@ The rendered result will be:
```
-### Multiple Insertion Points
+### 多插入点
-`` elements have a special attribute, `select`, which expects a CSS selector. You can have multiple `` insertion points with different `select` attributes, and each of them will be replaced by the elements matching that selector from the original content.
+`` 元素有一个特殊属性 `select`,需要赋值为一个 CSS 选择器。可以使用多个包含不同 `select` 属性的 `` 插入点,它们会被原始内容中与选择器匹配的部分所替代。
-Template for `multi-insertion-component`:
+`multi-insertion-component` 的模板:
``` html
@@ -530,7 +530,7 @@ Template for `multi-insertion-component`:
```
-Parent markup:
+父标签:
``` html
@@ -540,7 +540,7 @@ Parent markup:
```
-The rendered result will be:
+渲染结果如下:
``` html
@@ -550,6 +550,6 @@ The rendered result will be:
```
-The content insertion mechanism provides fine control over how original content should be manipulated or displayed, making components extremely flexible and composable.
+内容插入机制能很好地控制对原始内容的操作和显示,使组件极为灵活多变易于组合。
-Next: [Applying Transition Effects](/guide/transitions.html).
+下一节:[过渡效果](../guide/transitions.html)
diff --git a/source/guide/computed.md b/source/guide/computed.md
index 888d11b52f..4d93c9f53c 100644
--- a/source/guide/computed.md
+++ b/source/guide/computed.md
@@ -1,11 +1,11 @@
-title: Computed Properties
+title: 可推导的属性
type: guide
order: 8
---
-Vue.js' inline expressions are very convenient, but the best use cases for them are simple boolean operations or string concatenations. For more complicated logic, you should use **computed properties**.
+Vue.js 的内联表达式非常方便,但它最好的用武之地其实是简单的布尔操作或字符串拼接。如果涉及更复杂的逻辑,你应该使用**可推导的属性**。
-In Vue.js, you define computed properties with the `computed` option:
+在 Vue.js 中,你可以通过 `computed` 选项定义可推导的属性:
``` js
var demo = new Vue({
@@ -32,7 +32,7 @@ var demo = new Vue({
demo.fullName // 'Foo Bar'
```
-When you only need the getter, you can provide a single function instead of an object:
+当你只需要 getter 的时候,你可以用一个简单的函数替代该对象:
``` js
// ...
@@ -44,8 +44,8 @@ computed: {
// ...
```
-A computed property is essentially a property defined with getter/setter functions. You can use a computed property just like a normal property, but when you access it, you get the value returned by the getter function; when you change its value, you trigger the setter function passing in the new value as its argument.
+一个可推导的属性本质上是一个被 getter/setter 函数定义了的属性。可推导的属性使用起来和一般属性一样,只是在访问它的时候,你会得到 getter 函数返回的值,改变它的时候,你会触发 setter 函数并接收新赋的值。
-Before Vue.js 0.11 there used to be a dependency collection gotcha which requires users to explicitly list dependencies when conditional statements are involved. Starting with 0.11 it is no longer necessary to do so.
+在 Vue.js 0.11 之前的版本中,曾经有依赖收集机制,需要用户在条件语句中显性列出依赖关系。而在 0.11 之后你已经无需这样做了。
-Next, let's learn about how to [write a custom directive](/guide/custom-directive.html).
\ No newline at end of file
+接下来,我们学一学如何[撰写一个自定义的指令](../guide/custom-directive.html).
\ No newline at end of file
diff --git a/source/guide/custom-directive.md b/source/guide/custom-directive.md
index 6977f92dd4..3663288b89 100644
--- a/source/guide/custom-directive.md
+++ b/source/guide/custom-directive.md
@@ -1,15 +1,15 @@
-title: Custom Directives
+title: 自定义指令
type: guide
order: 9
---
-## The Basics
+## 基础
-Vue.js allows you to register custom directives, essentially enabling you to teach Vue new tricks on how to map data changes to DOM behavior. You can register a global custom directive with the `Vue.directive(id, definition)` method, passing in a **directive id** followed by a **definition object**. A definition object can provide several hook functions (all optional):
+Vue.js允许你注册自定义指令,实质上是让你教Vue一些新技巧:怎样将数据的变化映射成DOM的行为。你可以使用`Vue.directive(id, definition) `的方法传入**指令名称**和**定义对象**来注册一个全局自定义指令。定义对象要能提供一些钩子函数(全都可选):
-- **bind**: called only once, when the directive is first bound to the element.
-- **update**: called for the first time immediately after `bind` with the initial value, then again whenever the binding value changes. The new value and the previous value are provided as the argument.
-- **unbind**: called only once, when the directive is unbound from the element.
+- **bind**:仅调用一次,当指令第一次绑定元素的时候。
+- **update**: 第一次调用是在 bind之后,用的是初始值;以后每当绑定的值发生变化就会被调用,新值与旧值作为参数。
+- **unbind**:仅调用一次,当指令解绑元素的时候。
**Example**
@@ -31,13 +31,13 @@ Vue.directive('my-directive', {
})
```
-Once registered, you can use it in Vue.js templates like this (you need to add the Vue.js prefix to it):
+一旦注册好自定义指令,你就可以在Vue.js模板中像这样来使用它(你需要提前加上Vue.js):
``` html
```
-When you only need the `update` function, you can pass in a single function instead of the definition object:
+当你只用到`update`函数,你就可以只传入一个函数,而不用传定义对象:
``` js
Vue.directive('my-directive', function (value) {
@@ -45,18 +45,18 @@ Vue.directive('my-directive', function (value) {
})
```
-All the hook functions will be copied into the actual **directive object**, which you can access inside these functions as their `this` context. The directive object exposes some useful properties:
+所有的钩子函数会被复制到实际的**指令对象**中,而指令对象就是访问这些函数时的 `this`上下文环境。指令对象有一些有用的公开属性:
-- **el**: the element the directive is bound to.
-- **vm**: the context ViewModel that owns this directive.
-- **expression**: the expression of the binding, excluding arguments and filters.
-- **arg**: the argument, if present.
-- **raw**: the raw, unparsed expression.
-- **name**: the name of the directive, without the prefix.
+- **el**: 指令绑定的元素
+- **vm**: 拥有该指令的上下文视图模型
+- **expression**: 绑定的表达式,不包括参数和过滤器
+- **arg**: 当前参数
+- **raw**: 未被解析的原始表达式
+- **name**: 不带前缀的指令名
-You should treat all these properties as read-only and refrain from changing them. You can attach custom properties to the directive object too, but be careful not to accidentally overwrite existing internal ones.
+ 你应该把所有的这些属性看成是只读的,并且限制它们发生改变。你也可以给指令对象附加自定义的属性,但是注意不要重写已有的内部属性。
-An example of a custom directive using some of these properties:
+下面是自定义指令使用其中一些属性的例子:
``` html
@@ -111,9 +111,10 @@ var demo = new Vue({
})
-## Literal Directives
+## 直接指令
-If you pass in `isLiteral: true` when creating a custom directive, the attribute value will be taken as a literal string and assigned as that directive's `expression`. The directive will not attempt to setup data observation.
+如果在创建自定义指令的时候传入 `isLiteral: true` ,那么属性值就会被看成直接字符串,并被指定为该指令的`表达式`。指令不会试图建
+立数据监视。
Example:
@@ -130,19 +131,20 @@ Vue.directive('literal-dir', {
})
```
-### Dynamic Literal
+### 动态直接量
-However, in the case that the literal directive contains mustache tags, the behavior is as follows:
+然而,在直接指令含有mustache标签的情形下,指令的行为如下所示:
-- The directive instance will have a flag `this._isDynamicLiteral` set to `true`;
+- 指令实例会有一个标记,`this._isDynamicLiteral` 被设为 `true`
-- If no `update` function is provided, the mustache expression will be evaluated only once and assigned to `this.expression`. No data observation happens.
+- 如果没有提供 `update` 函数,mustache表达式只会被计算一次,并将值赋给 `this.expression` 。不会对表达式进行数据监视。
-- If an `update` function is provided, the directive **will** setup data observation for that expression and call `update` when the evaluated result changes.
+- 如果提供了 `update` 函数,指令**将**会为表达式建立一个数据监视,并且在计算结果变化的时候调用 `update`
-## Two-way Directives
-If your directive expects to write data back to the Vue instance, you need to pass in `twoWay: true`. This option allows the use of `this.set(value)` inside the directive:
+## 双向指令
+
+如果你的指令想向 Vue 实例写回数据,你需要传入 `twoWay: true` 。该选项允许在指令中使用 `this.set(value)`
``` js
Vue.directive('example', {
@@ -163,9 +165,9 @@ Vue.directive('example', {
})
```
-## Inline Statements
+## 内联声明
-Passing in `acceptStatement:true` enables your custom directive to accept inline statements like `v-on` does:
+传入 `acceptStatement:true` 可以让自定义指令像 `v-on` 一样接受内联声明:
``` html
@@ -182,11 +184,11 @@ Vue.directive('my-directive', {
})
```
-Use this wisely though, because in general you want to avoid side-effects in your templates.
+但是要聪明地使用它,因为通常情况下你是想避免它在你的模板中产生副作用。
-## Deep Observation
+## 深度监视
-If your custom directive is expected to be used on an Object, and it needs to trigger `update` when a nested property inside the object changes, you need to pass in `deep: true` in your directive definition.
+如果你希望在一个 `Object` 上使用自定义指令,并且当对象的内嵌属性发生变化时触发指令的 `update` 函数,那么你就要在指令的定义中传入 `deep: true` 。
``` html
@@ -202,10 +204,10 @@ Vue.directive('my-directive', {
})
```
-## Directive Priority
+## 指令优先级
-You can optionally provide a priority number for your directive (defaults to 0). A directive with a higher priority will be processed earlier than other directives on the same element. Directives with the same priority will be processed in the order they appear in the element's attribute list, although that order is not guaranteed to be consistent in different browsers.
+你可以选择给指令提供一个优先级数(默认是0)。同一个元素上优先级越高的指令会比其他的指令处理得早一些。优先级一样的指令会按照其在元素属性列表中出现的顺序依次处理,但是不能保证这个顺序在不同的浏览器中是一致的。
-You can checkout the priorities for some built-in directives in the [API reference](/api/directives.html). Additionally, `v-repeat`, `v-if` and `v-component` are considered "terminal directives" and they always have the highest priority in the compilation process.
+你可以去[API reference](../api/directives.html)看一些内置指令的优先级。另外,`v-repeat`, `v-if` 以及 `v-component` 被视为“终端指令”,它们在编译过程中始终拥有最高的优先级。
-Next, we'll see how to [write a custom filter](/guide/custom-filter.html).
\ No newline at end of file
+下面,我们来看怎样写一个[自定义过滤器](../guide/custom-filter.html)。
diff --git a/source/guide/custom-filter.md b/source/guide/custom-filter.md
index 556f25ea04..1fd51b79e1 100644
--- a/source/guide/custom-filter.md
+++ b/source/guide/custom-filter.md
@@ -1,11 +1,11 @@
-title: Custom Filters
+title: 自定义过滤器
type: guide
order: 10
---
-## The Basics
+## 基本用法
-Similar to custom directives, you can register a custom filter with the global `Vue.filter()` method, passing in a **filterID** and a **filter function**. The filter function takes a value as the argument and returns the transformed value:
+和自定义指令类似,你可以用全局方法 `Vue.filter()`,传递一个**过滤器 ID**和一个**过滤器函数**,注册一个自定义过滤器。过滤器函数会接受一个参数值并返回将其转换后的值:
``` js
Vue.filter('reverse', function (value) {
@@ -18,7 +18,7 @@ Vue.filter('reverse', function (value) {
```
-The filter function also receives any inline arguments:
+过滤器函数也接受任何内联的参数:
``` js
Vue.filter('wrap', function (value, begin, end) {
@@ -31,9 +31,9 @@ Vue.filter('wrap', function (value, begin, end) {
```
-## Two-way Filters
+## 双向过滤器
-Up till now we have used filters to transform values coming from the model and before displaying them in the view. But it is also possible to define a filter that transforms the value before it is written back to the model from the view (input elements):
+现在我们已经在展示视图之前用过滤器把模型里的值进行了转换。其实我们也可以定义一个过滤器在值从视图 (input 元素) 写回模型之前进行转换:
``` js
Vue.filter('check-email', {
@@ -50,9 +50,9 @@ Vue.filter('check-email', {
})
```
-## Filter Context
+## 过滤器上下文
-When a filter is invoked, its `this` context is set to the Vue instance that is invoking it. This allows it to output dynamic results based on the state of the owner Vue instance.
+当一个过滤器被调用的时候,其 `this` 上下文会被设置为调用它的 Vue 实例。这使得我们可以根据其所属的 Vue 实例动态输出结果。
For example:
@@ -67,8 +67,8 @@ Vue.filter('concat', function (value, key) {
{{msg | concat userInput}}
```
-For this simple example above, you can achieve the same result with just an expression, but for more complicated procedures that need more than one statements, you need to put them either in a computed property or a custom filter.
+在上面这个例子中,你用表达式即可完成相同的结果。但是面对更复杂的处理时,如果需要不止一个语句,你就得把它们放到一个可推导的属性中或一个自定义过滤器中。
-The built-in `filterBy` and `orderBy` filters are both filters that perform non-trivial work on the Array being passed in and relies on the current state of the owner Vue instance.
+内建的 `filterBy` 和 `orderBy` 过滤器都是根据传入的数组以及所属 Vue 实例状态而运行的过滤器。
-Alright! Now it's time to learn how the [Component System](/guide/components.html) works.
\ No newline at end of file
+Alright!是时候了解[组件系统](../guide/components.html)的工作方式了。
\ No newline at end of file
diff --git a/source/guide/directives.md b/source/guide/directives.md
index 02248e56b3..2c7565ef1a 100644
--- a/source/guide/directives.md
+++ b/source/guide/directives.md
@@ -1,11 +1,11 @@
-title: Directives
+title: 指令
type: guide
order: 3
---
-## Synopsis
+## 摘要
-If you have not used AngularJS before, you probably don't know what a directive is. Essentially, a directive is some special token in the markup that tells the library to do something to a DOM element. In Vue.js, the concept of directive is drastically simpler than that in Angular. A Vue.js directive can only appear in the form of a prefixed HTML attribute that takes the following format:
+如果你还没有使用过 AngularJS,你可能不太清楚指令 (directive) 是什么。一个指令的本质是一个特殊的标记符号,使得该库对一个 DOM 元素进行一些处理。在 Vue.js 中,指令的概念和 Angular 是完全一样的。Vue.js 中的指令就是带有特殊前缀的 HTML 特性,它会以下面的格式出现:
``` html
```
-## A Simple Example
+## 一个简单的例子
``` html
```
-Here the prefix is `v` which is the default. The directive ID is `text` and the the expression is `message`. This directive instructs Vue.js to update the div's `textContent` whenever the `message` property on the Vue instance changes.
+这里默认的前缀是 `v`。指令 ID 是 `text`,表达式是 `message`。该指令会在该 Vue 实例的 `message` 属性发生变化时更新这个 div 的 `textContent`。
-## Inline Expressions
+## 内联表达式
``` html
```
-Here we are using a computed expression instead of a single property key. Vue.js automatically tracks the properties an expression depends on and refreshes the directive whenever a dependency changes. Thanks to async batch updates, even when multiple dependencies change, an expression will only be updated once every event loop.
+这里我们用一个可推导的表达式 (computed expression) 提到了简单的属性名。Vue.js 会自动跟踪表达式中依赖的属性并在这些依赖发生变化的时候更新指令。而且因为有异步批处理更新机制,哪怕多个依赖同时变化时,表达式也只会在时间循环里触发一次。
-You should use expressions wisely and avoid putting too much logic in your templates, especially statements with side effects (with the exception of event listener expressions). To discourage the overuse of logic inside templates, Vue.js inline expressions are limited to **one statement only**. For bindings that require more complicated operations, use [Computed Properties](/guide/computed.html) instead.
+你应该灵活的使用表达式,以避免在你的模板里放入过多的逻辑,尤其是有边界效应的语句 (事件监听表达式除外)。为了在模板内防止逻辑被滥用,Vue.js 把内联表达式限制为**只能是一条语句**。如果需要绑定更复杂的操作,请使用[可推导的属性](../guide/computed.html)。
-For security reasons, in inline expressions you can only access properties and methods present on the current context Vue instance and its parents.
+由于安全方面的原因,在内联表达式中你只能访问当前上下文中 Vue 实例及其祖先的属性和方法。
-## Argument
+## 参数
``` html
```
-Some directives require an argument before the keypath or expression. In this example the `click` argument indicates we want the `v-on` directive to listen for a click event and then call the `clickHandler` method of the ViewModel instance.
+有些指令需要在路径或表达式前加一个参数。在这个例子中 `click` 参数代表了我们希望 `v-on` 指令监听到点击事件之后调用该 ViewModel 实例的 `clickHandler` 方法。
-## Filters
+## 过滤器
-Filters can be appended to directive keypaths or expressions to further process the value before updating the DOM. Filters are denoted by a single pipe (`|`) as in shell scripts. For more details see [Filters in Depth](/guide/filters.html).
+过滤器可以紧跟在指令的路径或表达式之后,在更新 DOM 之前对值进行进一步处理。过滤器会被像 shell 脚本一样表示在一个竖线 (`|`) 之后。更多内容请移步至[深入了解过滤器](../guide/filters.html)。
-## Multiple Clauses
+## 多重语句指令
-You can create multiple bindings of the same directive in a single attribute, separated by commas. Under the hood they are bound as multiple directive instances.
+你可以在同一个特性的同一个指令里创建多个绑定。这些绑定是用逗号分隔开的。它们在底层被分解为多个指令实例进行绑定。
``` html
```
-Here `"my-component"` is not a data property - it's a string ID that Vue.js uses to lookup the corresponding Component constructor.
+这里的 `"my-component"` 并不是一个数据属性——它是一个字符串 ID,用来让 Vue.js 查找对应的组件构造函数。
-You can also use mustache expressions inside literal directives. For example, the following code allows you to dynamically resolve the type of component you want to use:
+你也可以在字面量指令中使用 mustache 表达式。比如,下面的代码允许你动态的解析你想要的组件类型:
``` html
```
-When the expression inside the mustaches change, the rendered component will also change accordingly!
+当花括号内部的表达式改变时,渲染出来的组件也会随之改变哦!
-However, note that `v-component` and `v-partial` are the only literal directives that have this kind of reactive behavior. Mustache expressions in other literal directives, e.g. `v-ref`, are evaluated **only once**. After the directive has been compiled, it will no longer react to value changes.
+尽管如此,值得注意的是只有 `v-component` 和 `v-partial` 这两个字面量指令有这种可响应的行为。Mustache 表达式在别的字面量指令,如 `v-ref` 中,是**只运行一次**的。在指令被编译之后,就不再响应值的变化了。
-A full list of literal directives can be found in the [API reference](/api/directives.html#Literal_Directives).
+完整的字面量指令列表可以在 [API 索引](../api/directives.html#字面指令) 中找到。
-## Empty Directives
+## 空指令
-Some directives don't even expect an attribute value - they simply do something to the element once and only once. For example the `v-pre` directive:
+有些指令并不需要判断特性的值——这些操作对某个元素处理且仅处理一次。比如 `v-pre` 指令:
``` html
@@ -90,6 +90,6 @@ Some directives don't even expect an attribute value - they simply do something
```
-A full list of empty directives can be found in the [API reference](/api/directives.html#Empty_Directives).
+完整的空指令列表可以在 [API 索引](../api/directives.html#空指令) 中找到。
-Next, let's talk about [Filters](/guide/filters.html).
\ No newline at end of file
+接下来,我们来看一看[过滤器](../guide/filters.html)。
\ No newline at end of file
diff --git a/source/guide/events.md b/source/guide/events.md
index f8eef8f9e3..8cb656a483 100644
--- a/source/guide/events.md
+++ b/source/guide/events.md
@@ -1,9 +1,9 @@
-title: Listening for Events
+title: 事件监听
type: guide
order: 6
---
-You can use the `v-on` directive to bind event listeners to DOM events. It can be bound to either an event handler function (without the invocation parentheses) or an inline expression. If a handler function is provided, it will get the original DOM event as the argument. The event also comes with an extra property: `targetVM`, pointing to the particular ViewModel the event was triggered on:
+你可以使用 `v-on` 指令来绑定并监听 DOM 事件。绑定的内容可以是一个事件句柄函数 (后面无需跟括号) 或一个内联表达式。如果提供的是一个句柄函数,则原来的 DOM event 对象会被作为第一个参数传入,同时这个 event 对象会附带 `targetVM` 属性,指向触发该事件的相应的 ViewModel:
``` html
@@ -27,9 +27,9 @@ new Vue({
})
```
-## Invoke Handler with Expression
+## 执行表达式句柄
-`targetVM` could be useful when `v-on` is used with `v-repeat`, since the latter creates a lot of child ViewModels. However, it is often more convenient to use an invocation expression passing in `this`, which equals the current context ViewModel:
+`targetVM` 在 `v-repeat` 里使用 `v-on` 时显得特别有用,因为 `v-repeat` 会创建大量子 ViewModel。这样的话,通过执行表达式的方式,把代表当前上下文 ViewModel 的 `this` 传进去,就显得非常方便。
``` html
@@ -54,7 +54,7 @@ new Vue({
})
```
-When you want to access the original DOM event in an expression handler, you can pass it in as `$event`:
+当你想要在表达式句柄中访问原来的 DOM event,你可以传递一个 `$event` 参数进去:
``` html
Submit
@@ -72,30 +72,30 @@ When you want to access the original DOM event in an expression handler, you can
/* ... */
```
-## The Special `key` Filter
+## 特殊的 `key` 过滤器
-When listening for keyboard events, we often need to check for common key codes. Vue.js provides a special `key` filter that can only be used with `v-on` directives. It takes a single argument that denotes the key code to check for:
+当监听键盘事件时,我们常常需要判断常用的 key code。Vue.js 提供了一个特殊的只能用在 `v-on` 指令的过滤器:`key`。它接收一个表示 key code 的参数并完成判断:
```
```
-It also has a few presets for commonly used keys:
+它也预置了一些常用的按键名:
```
```
-Check the API reference for a [full list of key filter presets](/api/filters.html#key).
+API 索引中有 [key 过滤器预置的完整列表](../api/filters.html#key).
-## Why Listeners in HTML?
+## 为什么要在 HTML 中写监听器?
-You might be concerned about this whole event listening approach violates the good old rules about "separation of concern". Rest assured - since all Vue.js handler functions and expressions are strictly bound to the ViewModel that's handling the current View, it won't cause any maintainance difficulty. In fact, there are several benefits in using `v-on`:
+你可能会注意到整个事件监听的方式违背了“separation of concern”的传统理念。不必担心,因为所有的 Vue.js 句柄函数和表达式都严格绑定在当前视图的 ViewModel 上,它不会导致任何维护困难。实际上,使用 `v-on` 还有更多好处:
-1. It makes it easier to locate the handler function implementations within your JS code by simply skimming the HTML template.
-2. Since you don't have to manually attach event listeners in JS, your ViewModel code can be pure logic and DOM-free. This makes it easier to test.
-3. When a ViewModel is destroyed, all event listeners are automatically removed. You don't need to worry about cleaning it up yourself.
+1. 它便于在 HTML 模板中轻松定位 JS 代码里的句柄函数实现。
+2. 因为你无须在 JS 里手动绑定事件,你的 ViewModel 代码可以是非常纯粹的逻辑而和 DOM 无关。这会更易于测试。
+3. 当一个 ViewModel 被销毁时,所有的事件监听都会被自动移除。你无须担心如何自行清理它们。
-Next up: [Handling Forms](/guide/forms.html).
\ No newline at end of file
+接下来:[处理表单](../guide/forms.html).
\ No newline at end of file
diff --git a/source/guide/extending.md b/source/guide/extending.md
index 69a4f501dd..8fb42fec89 100644
--- a/source/guide/extending.md
+++ b/source/guide/extending.md
@@ -1,11 +1,11 @@
-title: Extending Vue
+title: 扩展 Vue
type: guide
order: 14
---
-## Extend with Mixins
+## 使用 Mixin 进行扩展
-Mixins are a flexible way to distribute reusable functionalities for Vue components. You can write a mixin just like a normal Vue component option object:
+Mixin 是一种为 Vue 组件分发可复用功能的灵活的方式。你可以像写一个普通 Vue 组件的选项对象一样写出一个 mixin:
``` js
// mixin.js
@@ -30,17 +30,17 @@ var Component = Vue.extend({
var component = new Component() // -> "hello from mixin!"
```
-## Extend with Plugins
+## 使用插件进行扩展
-Plugins usually adds global-level functionality to Vue.
+通常插件会为 Vue 添加一个全局的功能。
-### Writing a Plugin
+### 撰写插件
-There are typically several types of plugins you can write:
+你可以撰写以下几种典型类型的插件:
-1. Add one or more global methods. e.g. [vue-element](https://github.com/vuejs/vue-element)
-2. Add one or more global assets: directives/filters/transitions etc. e.g. [vue-touch](https://github.com/vuejs/vue-touch)
-3. Add some Vue instance methods by attaching them to Vue.prototype. The convention here is Vue instance methods should be prefixed with `$`, so that they don't conflict with user data and methods.
+1. 添加一个或几个全局方法。比如 [vue-element](https://github.com/vuejs/vue-element)
+2. 添加一个或几个全局资源:指令、过滤器、过渡效果等。比如 [vue-touch](https://github.com/vuejs/vue-touch)
+3. 通过绑定到 `Vue.prototype` 的方式添加一些 Vue 实例方法。这里有个约定,就是 Vue 的实例方法应该带有 `$` 前缀,这样就不会和用户的数据和方法产生冲突了。
``` js
exports.install = function (Vue, options) {
@@ -50,9 +50,9 @@ exports.install = function (Vue, options) {
}
```
-### Using a Plugin
+### 使用插件
-Assuming using a CommonJS build system:
+假设我们使用的构建系统是 CommonJS,则:
``` js
var vueTouch = require('vue-touch')
@@ -60,7 +60,7 @@ var vueTouch = require('vue-touch')
Vue.use(vueTouch)
```
-You can also pass in additional options to the plugin:
+你也可以向插件里传递额外的选项:
```js
Vue.use('my-plugin', {
@@ -68,9 +68,9 @@ Vue.use('my-plugin', {
})
```
-## Existing Tools
+## 现有的工具
-- [vue-devtools](https://github.com/vuejs/vue-devtools): A Chrome devtools extension for debugging Vue.js applications.
-- [vue-touch](https://github.com/vuejs/vue-touch): Add touch-gesture directives using Hammer.js.
-- [vue-element](https://github.com/vuejs/vue-element): Register Custom Elements with Vue.js.
-- [List of User Contributed Tools](https://github.com/yyx990803/vue/wiki/User-Contributed-Components-&-Tools)
\ No newline at end of file
+- [vue-devtools](https://github.com/vuejs/vue-devtools):一个用来 debug Vue.js 应用程序的 Chrome 开发者工具扩展。
+- [vue-touch](https://github.com/vuejs/vue-touch):添加基于 Hammer.js 的触摸手势的指令。
+- [vue-element](https://github.com/vuejs/vue-element): 用 Vue.js 注册 Custom Elements。
+- [用户贡献的工具列表](https://github.com/yyx990803/vue/wiki/User-Contributed-Components-&-Tools)
\ No newline at end of file
diff --git a/source/guide/faq.md b/source/guide/faq.md
index 4ba4de9bc0..b0770d14fb 100644
--- a/source/guide/faq.md
+++ b/source/guide/faq.md
@@ -1,62 +1,62 @@
-title: Common FAQs
+title: 常见问题
type: guide
order: 15
---
-- **Why doesn't Vue.js support IE8?**
+- **为什么Vue.js不支持IE8?**
- Vue.js is able to deliver the plain JavaScript object syntax without resorting to dirty checking by using `Object.defineProperty`, which is an ECMAScript 5 feature. It only works on DOM elements in IE8 and there's no way to polyfill it for JavaScript objects.
+ Vue.js能够在不使用`Object.defineProperty`的情况下进行脏检查来输出纯真的JavaScript对象语法,这是ECMAScript 5的一个特性。但它只在IE8的DOM元素中起作用,目前没有办法将其适用于JavaScript对象。
-- **So Vue.js modifies my data?**
+- **那么Vue.js修改了我的数据喽?**
- Yes and No. Vue.js only converts normal properties into getters and setters so it can get notified when the properties are accessed or changed. When serialized, your data will look exactly the same. There are, of course, some caveats:
+ 是也不是。Vue.js只转换正常的属性到getters和setters,这样它才能在属性被访问或更改时得到通知。而序列化时,你的数据将是完全相同。当然,这里有一些注意事项:
- 1. When you `console.log` observed objects you will only see a bunch of getter/setters. However you can use `vm.$log()` to log a more inspectable output.
+ 1. 当你使用`console.log`观察对象时你将只能看到一串getter/setters. 但你可以使用`vm.$log()`来打印出一个更直观的输出。
- 2. You cannot define your own getter/setters on data objects. This isn't much of a problem because data objects are expected to be obtained from plain JSON and Vue.js provides computed properties.
+ 2. 你不能定义数据对象的getter/setters。这不会是问题,因为数据对象都期望从纯JSON中取得,而且vue.js提供该提取属性。
- 3. Vue.js adds a few extra properties/methods to obsesrved objects: `__ob__`, `$add` and `$delete`. These properties are inenumberable so they will not show up in `for ... in ...` loops. However if you overwrite them things will likely break.
+ 3. Vue.js添加了一些拓展的属性或方法来观察对象: `__ob__`, `$add`以及`$delete`. 这些属性是内部的所以它们不会显示在`for ... in ...`循环中. 但是如果你覆盖了它们这可能就破坏掉了。
- That's pretty much it. Accessing properties on the object is the same as before, `JSON.stringify` and `for ... in ...` loops will work as normal. 99.9% of the time you don't even need to think about it.
+ 类似的东西还有一些。基于对象访问属性和以前一样,`JSON.stringify`和`for ... in ...`循环照常运行。99.9%的情况下你甚至不需要考虑它们。
-- **What is the current status of Vue.js? Can I use it in production?**
+- **Vue.js目前的状态怎样? 我能把它应用在生产环节么?**
- Vue.js has undergone some major rewrite for the 0.11 update, and we are now working towards the 1.0 release. Vue.js is already being used in production at companies like Optimizely.
+ Vue.js 0.11的更新已经经历了一些重大的修改,我们正在朝着1.0的发布版本迈进。Vue.js已经被像Optimizely这样的公司应用在生产环境中。
-- **Is Vue.js free to use?**
+- **Vue.js是免费试用的吗?**
- Vue.js is free and fully open sourced under the MIT License.
+ Vue.js遵循MIT协议是免费且完全开源的.
-- **What is the difference between Vue.js and AngularJS?**
+- **Vue.js和AngularJS之间的区别是什么?**
- There are a few reasons to use Vue over Angular, although they might not apply for everyone:
+ 下面是一些使用Vue而不是Angular的原因,但它们不适用于每一个人:
- 1. Vue.js is a more flexible, less opinionated solution. That allows you to structure your app the way you want it to be, instead of being forced to do everything the Angular way. It's only an interface layer so you can use it as a light feature in pages instead of a full blown SPA. It gives you bigger room to mix and match with other libraries. This is probably the most important distinction.
+ 1. Vue.js是一个更加灵活开放的解决方案。它允许你以希望的方式组织你的应用程序,而不是像Angular那样强迫去做。它仅仅是一个接口层,所以你可以将它作为一个页面的轻特性而不是一个全栈的SPA。在结合和匹配其他库方面它给了你更大的的空间。这可能是最为重要的区别。
- 2. Vue.js is much simpler than Angular in general, so you can learn almost everything about it really fast and get productive.
+ 2. 总体来说Vue.js比Angular简单, 因此你可以快速地学习它的方方面面并投入生产.
- 3. Vue.js has better performance because it doesn't use dirty checking. Angular gets slow when there are a lot of watchers, because every time anything in the scope changes, all these watchers need to be re-evaluated again. Vue.js doesn't suffer from this because it uses an event based observing mechanism, so all changes trigger independently unless they have explicit dependency relationships.
+ 3. Vue.js拥有更好的性能,因为它不使用脏检查。当观察点越来越多时Angular会变得越来越慢,因为作用域内的每一次变更所有的这些观察点都需要被重新评估。Vue.js不面临这些问题,这是因为它采用了基于事件的观察机制,所以所有的触发都是独立的,除非它们之间有明确的依赖关系。
- 4. Vue.js has a clearer separation between directives and components. Directives are meant to encapsulate DOM manipulations only, while Components stand for a self-contained unit that has its own view and data logic. In Angular there's a lot of confusion between the two.
+ 4. Vue.js指令和组件间具有一个清晰隔离。指令只意味着封装DOM操作,而组件代表一个子独立的单元——它拥有自己的视图和数据逻辑。在Angular中它们两者间有不少混淆。
- But also note that Vue.js is a relatively young project, while Angular is battle-proven, Google-sponsored, and has a larger community.
+ 但是需要指出的是Vue.js还是一个相对年轻的项目,而Angular已经久经项目验证,并且是谷歌发起的且有一个更大的社区。
-- **What makes Vue.js different from KnockoutJS?**
+- **是什么使得Vue.js不同于KnockoutJS?**
- First, Vue provides a cleaner syntax in getting and setting VM properties.
+ 首先,Vue在获取和设置虚拟属性上提供了更清晰的语法。
- On a higher level, Vue differs from Knockout in that Vue's component system encourages you to take a top-down, structure first, declarative design strategy, instead of imperatively build up ViewModels from bottom up. In Vue the source data are plain, logic-less objects (ones that you can directly JSON.stringify and throw into a post request), and the ViewModel simply proxies access to that data on itself. A Vue VM instance always connects raw data to a corresponding DOM element. In Knockout, the ViewModel essentially **is** the data and the line between Model and ViewModel is pretty blurry. This lack of differentiation makes Knockout more flexible, but also much more likely to result in convoluted ViewModels.
+ 从更高层次来说,Vue区别于Knockout是因为Vue的组件系统鼓励你采取自上而下,结构第一,陈述性设计的策略,而不是命令式的自下向上来建立ViewModel。在Vue中源数据是纯粹的无逻辑的对象(这些对象你可以直接JSON.stringify并扔到POST请求中),而ViewModel只是代理访问数据本身。Vue的VM实例往往连接原始数据及与其对应的DOM元素。在Knockout中,ViewModel基本**是**数据,Model和ViewModel之间的连线是很模糊的。这种分化的缺乏使得Knockout更灵活,但也更可能导致复杂的ViewModels。
-- **What makes Vue.js different from React.js?**
+- **是什么使得Vue.js不同于React.js?**
- React.js and Vue.js do have some similarity in that they both provide reactive & composable View components. However the internal implementation is fundamentally different. React is built upon a virtual DOM - an in-memory representation of what the actual DOM should look like. Data in React is largely immutable and DOM manipulations are calculated via diffing. On the contrary data in Vue.js is mutable and stateful by default, and changes are triggered through events. Instead of a virtual DOM, Vue.js uses the actual DOM as the template and keeps references to actual nodes for data bindings.
+ React.js和Vue.js确实有一些相似——它们都提供反射和组合视图组件。然而,它们的内部实现是完全不同的。React是基于虚拟DOM —— 在内存中的表述DOM看起来应该是怎样的。React中的数据大部分是不变的,而且DOM操作通过比较来计算的。与之相反Vue.js中的数据默认情况下是可变且优雅的,变更通过事件触发。相比于虚拟DOM,Vue.js使用实际的DOM作为模板,并且保持对真实节点的引用来进行数据绑定。
- The virtual-DOM approach provides a functional way to describe your view at any point of time, which is really nice. Because it doesn't use observables and re-renders the entire app on every update, the view is by definition guaranteed to be in sync with the data. It also opens up possiblities to isomorphic JavaScript applications.
+ 虚拟DOM的方法提供了一个功能性的方式以便在任何时候描述视图,这确实很好。因为它不使用观测值,且不需要为每个更新重新渲染整个应用,视图通过定义保证与数据保持同步。它也开辟了与JavaScript应用同构的可能性。
- Overall I'm a big fan of React's design philosophy myself. But one issue with React is that your logic and your view are tightly knit together. For some developers this is a bonus, but for designer/developer hybrids like me, having a template makes it much easier to think visually about the design and CSS. JSX mixed with JavaScript logic breaks that visual model I need to map the code to the design. In contrast, Vue.js pays the cost of a lightweight DSL (directives) so that we have a visually scannable template and with logic encapsulated into directives and filters.
+ 总的来说我自己就是React设计理念的忠实粉丝。但React有一个问题就是你的逻辑和视图是紧密结合在一起的。对于部分开发者来说这是件让人高兴的事,但对那些像我一样设计/开发混合进行的人来说,更希望能有一个模板,它能够更容易地在视觉上考虑设计和CSS。JSX和JavaScript逻辑的混合打破了我映射代码到设计的视觉模型。相反,Vue.js扮演了一个轻量级的DSL(指令型的) 的角色,这样我们有了一个直观的扫描模板,且能够将逻辑封装进指令和过滤器中。
- Another issue with React is that because DOM updates are completely delegated to the Virtual DOM, it's a bit tricky when you actually **want** to control the DOM yourself (although theoretically you can, you'd be essentially working against the library when you do that). For applications that needs complex time-choreographed animations, this can become a pretty annoying restriction. On this front, Vue.js allows for more flexibility and there are [multiple FWA/Awwwards winning sites](https://github.com/yyx990803/vue/wiki/Projects-Using-Vue.js#interactive-experiences) built with Vue.js.
+ React的另一个问题是:由于DOM更新完全下放给虚拟DOM,当你真的**想**自己控制DOM是就有点棘手了(虽然理论上你可以,但这样做时你本质上在对抗库原本的原则)。对于需要复杂时间控制的动画应用来说这就变成了一项很讨人厌的限制。在这方面,Vue.js允许更多的灵活性并且有不少用Vue.js构建的事例[一些FWA/Awwwards获奖站点](https://github.com/yyx990803/vue/wiki/Projects-Using-Vue.js#interactive-experiences)
-- **I want to help!**
+- **我要提供帮助!**
- Great! Read the [contribution guide](https://github.com/yyx990803/vue/blob/master/CONTRIBUTING.md) and join discussions on IRC (#vuejs).
\ No newline at end of file
+ 很好! 阅读 [贡献指导](https://github.com/yyx990803/vue/blob/master/CONTRIBUTING.md) 并加入IRC上的讨论 (#vuejs).
\ No newline at end of file
diff --git a/source/guide/filters.md b/source/guide/filters.md
index 03e74b398c..0422b84022 100644
--- a/source/guide/filters.md
+++ b/source/guide/filters.md
@@ -1,39 +1,39 @@
-title: Filters
+title: 过滤器
type: guide
order: 4
---
-## Synopsis
+## 摘要
-A Vue.js filter is essentially a function that takes a value, processes it, and then returns the processed value. In the markup it is denoted by a single pipe (`|`) and can be followed by one or more arguments:
+一个 Vue.js 的过滤器本质上是一个函数,这个函数会接收一个值,将其处理并返回。它被标记在一个竖线 (`|`) 之后,并可以跟随一个或多个参数:
``` html
```
-## Examples
+## 示例
-Filters must be placed at the end of a directive's value:
+过滤器必须放置在一个指令的值的最后:
``` html
```
-You can also use them inside mustache-style bindings:
+你也可以用在 mustache 风格的绑定的内部:
``` html
{{message | uppercase}}
```
-Multiple filters can be chained together:
+可以把多个过滤器链在一起:
``` html
{{message | lowercase | reverse}}
```
-## Arguments
+## 参数
-Some filters can take optional arguments. Simply add arguments separated by spaces:
+一些过滤器是可以附带参数的。只需用空格分隔开:
``` html
{{order | pluralize st nd rd th}}
@@ -43,6 +43,6 @@ Some filters can take optional arguments. Simply add arguments separated by spac
```
-For their specific use of the above examples see the [full list of built-in filters](/api/filters.html).
+上述示例的具体用法参见[完整的内建过滤器列表](../api/filters.html)。
-Now that you know what directives and filters are, let's get our hands dirty and try to [display a list of items](/guide/list.html).
\ No newline at end of file
+现在你已经了解了指令和过滤器,接下来我们趁热打铁[展示一个列表](../guide/list.html)吧。
\ No newline at end of file
diff --git a/source/guide/forms.md b/source/guide/forms.md
index b36d78dcf8..23b9246e07 100644
--- a/source/guide/forms.md
+++ b/source/guide/forms.md
@@ -1,13 +1,13 @@
-title: Handling Forms
+title: 处理表单
type: guide
order: 7
---
-## The Basics
+## 基本用法
-You can use the `v-model` directive to create two-way data bindings on form input elements. It automatically picks the correct way to update the element based on the input type.
+你可以在表单的 input 元素上使用 `v-model` 指令来创建双向数据绑定。它会根据 input type 自动选取正确的方式更新元素。
-**Example**
+**示例**
``` html
-## Lazy Updates
+## 懒更新
-By default, `v-model` syncs the input with the data after each `input` event. You can add a `lazy` attribute to change the behavior to sync after `change` events:
+默认情况下,`v-model` 会在每个 `input` 事件之后同步输入的数据。你可以添加一个 `lazy` 特性,将其改变为在每个 `change` 事件之后才完成同步。
``` html
```
-## Casting Value as Number
+## 当做数来处理
-If you want user input to be automatically persisted as numbers, you can add a `number` attribute to your `v-model` managed inputs:
+如果你希望用户的输入自动处理为一个数,你可以在 `v-model` 所在的 input 上添加一个 `number` 特性。
``` html
```
-## Dynamic Select Options
+## 动态 select 选项
-When you need to dynamically render a list of options for a `
` element, it's recommended to use an `options` attribute together with `v-model`:
+当你需要为一个 `` 元素动态渲染列表选项时,我们推荐 `options` 和 `v-model` 特性配合使用:
``` html
```
-In your data, `myOptions` should be an keypath/expression that points to an Array to use as its options. The Array can contain plain strings, or contain objects.
+在你的数据里,`myOptions` 应该是一个代表选项数组的路径/表达式。该数组可以包含普通字符串或对象。
-The object can be in the format of `{text:'', value:''}`. This allows you to have the option text displayed differently from its underlying value:
+该数组里对象的格式可以是 `{text:'', value:''}`。这允许你把展示的文字和其背后对应的值区分开来。
``` js
[
@@ -113,7 +113,7 @@ The object can be in the format of `{text:'', value:''}`. This allows you to hav
]
```
-Will render:
+会渲染成:
``` html
@@ -122,7 +122,8 @@ Will render:
```
-Alternatively, the object can be in the format of `{ label:'', options:[...] }`. In this case it will be rendered as an ``:
+另外,该数组里对象的格式也可以是 `{label:'', options:[...]}`。这样的数据会被渲染成为一个 ``:
``` js
[
@@ -131,7 +132,7 @@ Alternatively, the object can be in the format of `{ label:'', options:[...] }`.
]
```
-Will render:
+会渲染成:
``` html
@@ -146,4 +147,4 @@ Will render:
```
-Next: [Computed Properties](/guide/computed.html).
\ No newline at end of file
+接下来:[可推导的属性](../guide/computed.html).
\ No newline at end of file
diff --git a/source/guide/index.md b/source/guide/index.md
index e24f21ffb5..f4680c0754 100644
--- a/source/guide/index.md
+++ b/source/guide/index.md
@@ -1,113 +1,114 @@
-title: Getting Started
+title: 起步
type: guide
order: 2
---
-## Introduction
+## 介绍
-Vue.js is a library for building interactive web interfaces.
+Vue.js 是一个用于创建 web 交互界面的库。
-Technically, Vue.js is focused on the [ViewModel](#ViewModel) layer of the MVVM pattern. It connects the [View](#View) and the [Model](#Model) via two way data bindings. Actual DOM manipulations and output formatting are abstracted away into [Directives](#Directives) and [Filters](#Filters).
+从技术角度讲,Vue.js 专注于 MVVM 模型的 [ViewModel](#ViewModel) 层。它通过双向数据绑定把 [View](#View) 层和 [Model](#Model) 层连接了起来。实际的 DOM 封装和输出格式都被抽象为了 [Directives](#Directives) 和 [Filters](#Filters)。
-Philosophically, the goal is to provide the benefits of reactive data binding and composable view components with an API that is as simple as possible. It is not a full-blown framework - it is designed to be a view layer that is simple and flexible. You can use it alone for rapid prototyping, or mix and match with other libraries for a custom front-end stack. It's also a natural fit for no-backend services such as Firebase.
+从哲学角度讲,我们希望创造的价值,在于通过一个尽量简单的 API 产生可反映的数据绑定和可组合的视图组件。它不是一个大而全的框架——它为简单灵活的视图层而生。您可以独立使用它快速开发原型、也可以混合别的库做更多的事情。它同时天然的适用于诸如 Firebase 的 no-backend 服务。
-Vue.js' API is heavily influenced by [AngularJS], [KnockoutJS], [Ractive.js] and [Rivets.js]. Despite the similarities, I believe Vue.js offers a valuable alternative to these existing libraries by finding a sweetspot between simplicity and functionality.
+Vue.js 的 API 设计深受 [AngularJS]、[KnockoutJS]、[Ractive.js] 和 [Rivets.js] 的影响。尽管有不少雷同,但我们相信 Vue.js 能够通过在简约和功能两者之间的巧妙契合,体现出其特殊的价值。
-Even if you are already familiar with some of these terms, it is recommended that you go through the following concepts overview because your notion of these terms might be different from what they mean in the Vue.js context.
+即便您已经熟悉了一些这类的库或框架,我们还是推荐您继续阅读接下来的概览,因为您对它们的认识也许和 Vue.js 中的情景不尽相同。
-## Concepts Overview
+## 概览
### ViewModel
-An object that syncs the Model and the View. In Vue.js, every Vue instance is a ViewModel. They are instantiated with the `Vue` constructor or its sub-classes:
+一个同步 Model 和 View 的对象。在 Vue.js 中,每个 Vue 实例都是一个 ViewModel。它们是通过构造函数 `Vue` 或其子类被初始化出来的。
```js
var vm = new Vue({ /* options */ })
```
-This is the primary object that you will be interacting with as a developer when using Vue.js. For more details see [The Vue Constructor](/api/).
+这是您作为一个开发者在使用 Vue.js 时主要打交道的对象。更多的细节请移步至[Vue 构造函数](../api/)。
-### View
+### 视图 (View)
-The actual DOM that is managed by Vue instances.
+实际被 Vue 实例管理的 DOM。
```js
vm.$el // The View
```
-Vue.js uses DOM-based templating. Each Vue instance is associated with a corresponding DOM element. When a Vue instance is created, it recursively walks all child nodes of its root element while setting up the necessary data bindings. After the View is compiled, it becomes reactive to data changes.
+Vue.js 使用基于 DOM 的模板。每个 Vue 实例都关联着一个相应的 DOM 元素。当一个 Vue 实例被创建时,它会递归遍历根元素的所有子结点,同时完成必要的数据绑定。当这个视图被编译之后,它就会自动反映数据的变化。
-When using Vue.js, you rarely have to touch the DOM yourself except in custom directives (explained later). View updates will be automatically triggered when the data changes. These view updates are highly granular with the precision down to a textNode. They are also batched and executed asynchronously for greater performance.
+在使用 Vue.js 时,除了自定义的指令 (directives) 您几乎不必直接接触 DOM (稍后会有解释)。当数据发生变化时,视图将会自动触发更新。这些更新的颗粒度是精确到 textNode 的。同时为了更好的性能,这些更新是批量异步执行的。
-### Model
+### 模型 (Model)
-A slightly modified plain JavaScript object.
+一个轻微改动过的普通 JavaScript 对象。
```js
vm.$data // The Model
```
-In Vue.js, models are simply plain JavaScript objects, or **data objects**. You can manipulate their properties and Vue instances that are observing them will be notified of the changes. Vue.js achieves transparent reactivity by converting the properties on data objects into ES5 getter/setters. There's no need for dirty checking, nor do you have to explicitly signal Vue to update the View. Whenever the data changes, the View is updated on the next frame.
+Vue.js 中的模型就是普通的 JavaScript 对象——也可以称为**数据对象**。你可以操作它们的属性,同时 Vue 实例观察到这些属性的变化时也会被提示。Vue.js 把数据对象的属性都转换成了 ES5 中的 getter/setters,以此达到无副作用的数据观察效果。无需 dirty checking,也不需要刻意给 Vue 任何更新视图的信号。每当数据变化时,视图都会在下一帧自动更新。
-Vue instances proxy all properties on data objects they observe. So once an object `{ a: 1 }` has been observed, both `vm.$data.a` and `vm.a` will return the same value, and setting `vm.a = 2` will modify `vm.$data`.
+Vue 实例代理了它们观察到的数据对象的所有属性。所以一旦一个对象 `{ a: 1 }` 被观察,那么 `vm.$data.a` 和 `vm.a` 将会返回相同的值,而设置 `vm.a = 2` 则也会修改 `vm.$data`。
-The data objects are mutated in place, so modifying it by reference has the same effects as modifying `vm.$data`. This makes it possible for multiple Vue instances to observe the same piece of data. In larger applications it is also recommended to treat Vue instances as pure views, and externalize the data manipulation logic into a more discrete store layer.
+数据对象有时是突变的,所以修改数据的引用和修改 `vm.$data` 具有相同的效果。这也意味着多个 Vue 实例可以观察同一份数据。在较大型的应用程序中,我们也推荐将 Vue 实例作为纯粹的视图看待,同时把数据处理逻辑放在更独立的外部数据层。
-One caveat here is that once the observation has been initiated, Vue.js will not be able to detect newly added or deleted properties. To get around that, observed objects are augmented with `$add` and `$delete` methods.
+值得提醒的是,一旦数据被观察,Vue.js 就不会再侦测到新加入或删除的属性了。作为弥补,我们会为被观察的对象增加 `$add` 和 `$delete` 方法。
-### Directives
+### 指令 (Directives)
-Prefixed HTML attributes that tell Vue.js to do something about a DOM element.
+带特殊前缀的 HTML 特性,可以让 Vue.js 对一个 DOM 元素做各种处理。
```html
```
-Here the div element has a `v-text` directive with the value `message`. What it does is telling Vue.js to keep the div's textContent in sync with the Vue instance's `message` property.
+这里的 div 元素有一个 `v-text` 指令,其值为 `message`。Vue.js 会让该 div 的文本内容是和 Vue 实例中的 `message` 属性值保持一致。
-Directives can encapsulate arbitrary DOM manipulations. For example `v-attr` manipulates an element's attributes, `v-repeat` clones an element based on an Array, `v-on` attaches event listeners... we will cover them later.
+Directives 可以封装任何 DOM 操作。比如 `v-attr` 会操作一个元素的特性;`v-repeat` 会基于一个数组克隆某个元素;`v-on` 会绑定事件等。稍后会有更多的介绍。
-### Mustache Bindings
+### Mustache 风格的绑定
-You can also use mustache-style bindings, both in text and in attributes. They are translated into `v-text` and `v-attr` directives under the hood. For example:
+你也可以使用 mustache 风格的绑定,不管在文本中还是在特性中。它们在底层会被转换成 `v-text` 和 `v-attr` 的指令。比如:
```html
Hello {{name}}!
```
-Although it is convenient, there are a few things you need to be aware of:
+这很方便,不过有一些注意事项:
-The `src` attribute on an `` element makes an HTTP request when a value is set, so when the template is first parsed it will result in a 404. In this case `v-attr` is preferred.
+一个 `` 的 `src` 特性在赋值时会产生一个 HTTP 请求,所以当模板在第一次被解析时会产生一个 404 请求。这种情况下更适合用 `v-attr`。
-Internet Explorer will remove invalid inline `style` attributes when parsing HTML, so always use `v-style` when binding inline CSS if you want to support IE.
+Internet Explorer 在解析 HTML 时会移除非法的内联 `style` 特性,所以如果你想支持 IE,请在绑定内联 CSS 的时候始终使用 `v-style`。
-You can use triple mustaches for unescaped HTML, which translates to `v-html` internally:
+
+你可以使用三对花括号来回避 HTML 代码,而这种写法会在底层转换为 `v-html`:
``` html
{{{ safeHTMLString }}}
```
-However, this can open up windows for potential XSS attacks, therefore it is suggested that you only use triple mustaches when you are absolutely sure about the security of the data source, or pipe it through a custom filter that sanitizes untrusted HTML.
+不过这种用法会留下 XSS 攻击的隐患,所以建议只对绝对信任的数据来源使用三对花括号的写法,或者先通过自定义的过滤器 (filter) 对不可信任的 HTML 进行过滤。
-Finally, you can add `*` to your mustache bindings to indicate a one-time only interpolation, which does not react to data changes:
+最后,你可以在你的 mustache 绑定里加入 `*` 来注明这是一个一次性撰写的数据,这样的话它就不会反应后续的数据变化:
``` html
{{* onlyOnce }}
```
-### Filters
+### 过滤器 (Filters)
-Filters are functions used to process the raw values before updating the View. They are denoted by a "pipe" inside directives or bindings:
+过滤器是用于在更新视图之前处理原始值的函数。它们通过一个“管道”在指令或绑定中进行处理:
```html
{{message | capitalize}}
```
-Now before the div's textContent is updated, the `message` value will first be passed through the `capitalize` function. For more details see [Filters in Depth](/guide/filters.html).
+这样在 div 的文本内容被更新之前,`message` 的值会先传给 `capitalizie` 函数处理。更多内容可移步至[深入了解过滤器 (Filters)](../guide/filters.html)。
-### Components
+### 组件 (Components)
-In Vue.js, every component is simply a Vue instance. Components form a nested tree-like hierarchy that represents your application interface. They can be instantiated by a custom constructor returned from `Vue.extend`, but a more declarative approach is registering them with `Vue.component(id, constructor)`. Once registered, they can be declaratively nested in other Vue instance's templates with the `v-component` directive:
+在 Vue.js,每个组件都是一个简单的 Vue 实例。一个树形嵌套的各种组件就代表了你的应用程序的各种接口。通过 `Vue.extend` 返回的自定义构造函数可以把这些组件实例化,不过更声明式的建议是通过 `Vue.component(id, constructor)` 注册这些组件。一旦组件被注册,它们就可以在 Vue 实例的模板中以声明的形式嵌套使用了。
``` html
@@ -115,9 +116,9 @@ In Vue.js, every component is simply a Vue instance. Components form a nested tr
```
-This simple mechanism enables declarative reuse and composition of Vue instances in a fashion similar to [Web Components](http://www.w3.org/TR/components-intro/), without the need for latest browsers or heavy polyfills. By breaking an application into smaller components, the result is a highly decoupled and maintainable codebase. For more details, see [Component System](/guide/components.html).
+这个简单的机制使得我们可以以类似 [Web Components](http://www.w3.org/TR/components-intro/) 的声明形式对 Vue 实例进行复用和组合,无需最新版的浏览器或笨重的 polyfills。通过将一个应用程序拆分成简单的组件,代码库可以被尽可能的解耦,同时更易于维护。更多内容可移步至[组件系统](../guide/components.html)。
-## A Quick Example
+## 一个简单的例子
``` html
@@ -174,11 +175,11 @@ var demo = new Vue({
})
-Also available on [jsfiddle](http://jsfiddle.net/yyx990803/yMv7y/).
+也可以通过 [jsfiddle](http://jsfiddle.net/yyx990803/yMv7y/) 查看。
-You can click on a todo to toggle it, or you can open your Browser's console and play with the `demo` object - for example, change `demo.title`, push a new object into `demo.todos`, or toggle a todo's `done` state.
+你可以点击一个 todo 来开关它,也可以打开你的浏览器命令行直接操作 `demo` 对象:比如改变 `demo.title`、向 `demo.todos` 里放入一个新的对象、或开关某个 todo 的 `done` 状态值。
-You probably have a few questions in mind now - don't worry, we'll cover them soon. Next up: [Directives in Depth](/guide/directives.html).
+也许你脑海中还有一些问题,别担心,我们稍后都会提到的。接下来可移步至:[深入了解指令 (Directives)](../guide/directives.html)。
[AngularJS]: http://angularjs.org
[KnockoutJS]: http://knockoutjs.com
diff --git a/source/guide/installation.md b/source/guide/installation.md
index 0ba09cf137..3b8202c184 100644
--- a/source/guide/installation.md
+++ b/source/guide/installation.md
@@ -1,4 +1,4 @@
-title: Installation
+title: 安装
type: guide
order: 1
vue_version: 0.11.4
@@ -7,32 +7,32 @@ min_size: 55.18
gz_size: 18.11
---
-> **Compatibility Note:** Vue.js does not support IE8 and below.
+> **兼容性提示:**Vue.js 不支持 IE8 及其以下版本。
-## Standalone
+## 直接下载
-Simply download and include with a script tag. `Vue` will be registered as a global variable.
+直接下载并写入一个 script 标签中,`Vue` 就会被注册为一个全局变量。
-
Development Version {{dev_size}}kb, plenty of comments and debug/warning messages.
+
开发者版本 {{dev_size}}kb, plenty of comments and debug/warning messages.
-
Production Version {{min_size}}kb minified / {{gz_size}}kb gzipped
+
生产版本 {{min_size}}kb minified / {{gz_size}}kb gzipped
-Also available on [cdnjs](//cdnjs.cloudflare.com/ajax/libs/vue/{{vue_version}}/vue.min.js) (takes some time to sync so the latest version might not be available yet).
+也可以在 [cdnjs](http://cdnjs.cloudflare.com/ajax/libs/vue/{{vue_version}}/vue.min.js) 使用 (版本更新会略滞后)。
## NPM
``` bash
$ npm install vue
-# for edge version:
+# 获得尖端版本:
$ npm install yyx990803/vue#dev
```
## Bower
``` bash
-# only stable version is available through Bower
+# Bower 只能够获得稳定版本
$ bower install vue
```
@@ -40,7 +40,7 @@ $ bower install vue
```js
var Vue = require('yyx990803/vue')
-// for edge version:
+// 获得尖端版本:
var Vue = require('yyx990803/vue@dev')
```
@@ -48,14 +48,14 @@ var Vue = require('yyx990803/vue@dev')
``` bash
$ component install yyx990803/vue
-# for edge version:
+# 获得尖端版本:
$ component install yyx990803/vue@dev
```
-## AMD Module Loaders
+## AMD 模块加载器
-The standalone downloads or versions installed via Bower are wrapped with UMD so they can be used directly as an AMD module.
+直接下载或通过 Bower 安装的版本可以用 UMD 包裹起来直接作为 AMD 模块使用。
-## Ready?
+## 准备好了吗?
-[Let's Get Started](/guide/).
\ No newline at end of file
+[走起!](../guide/)
\ No newline at end of file
diff --git a/source/guide/list.md b/source/guide/list.md
index d5aab1612b..7118644ab2 100644
--- a/source/guide/list.md
+++ b/source/guide/list.md
@@ -1,11 +1,11 @@
-title: Displaying a List
+title: 列表展示
type: guide
order: 5
---
-You can use the `v-repeat` directive to repeat a template element based on an Array of objects on the ViewModel. For every object in the Array, the directive will create a child Vue instance using that object as its `$data` object. These child instances inherit all data on the parent, so in the repeated element you have access to properties on both the repeated instance and the parent instance. In addition, you get access to the `$index` property, which will be the corresponding Array index of the rendered instance.
+你可以使用 `v-repeat` 指令基于ViewModel上的对象数组来重复显示模板元素。对于数组中的每个对象,该指令将创建一个以该对象作为其 `$data` 对象的子Vue实例。这些子实例继承父实例的所有数据,因此在重复的模板元素中你既可以访问子实例的属性,也可以访问父实例的属性。此外,你还可以访问 `$index` 属性,其表示所呈现的实例在对象数组中对应的索引。.
-**Example:**
+**示例:**
``` html
@@ -28,7 +28,7 @@ var demo = new Vue({
})
```
-**Result:**
+**结果:**
{{$index}} - {{parentMsg}} {{childMsg}}
-## Arrays of Primitive Values
+## 简单值数组
-For Arrays containing primitive values, you can access the value simply as `$value`:
+对于包含简单值的数组,你可用 `$value` 直接访问值:
``` html
\ No newline at end of file
diff --git a/themes/vue/layout/partials/header.ejs b/themes/vue/layout/partials/header.ejs
index ac6837fab0..8153c323b3 100644
--- a/themes/vue/layout/partials/header.ejs
+++ b/themes/vue/layout/partials/header.ejs
@@ -1,6 +1,6 @@