Skip to content

Commit b8b5ad9

Browse files
author
勾股
committed
translated guide/extending
1 parent 508f797 commit b8b5ad9

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

source/guide/extending.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ type: guide
33
order: 14
44
---
55

6-
## Extend with Mixins
6+
## 使用 Mixin 进行扩展
77

8-
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:
8+
Mixin 是一种为 Vue 组件分发可复用功能的灵活的方式。你可以像写一个普通 Vue 组件的选项对象一样写出一个 mixin:
99

1010
``` js
1111
// mixin.js
@@ -30,17 +30,17 @@ var Component = Vue.extend({
3030
var component = new Component() // -> "hello from mixin!"
3131
```
3232

33-
## Extend with Plugins
33+
## 使用插件进行扩展
3434

35-
Plugins usually adds global-level functionality to Vue.
35+
通常插件会为 Vue 添加一个全局的功能。
3636

37-
### Writing a Plugin
37+
### 撰写插件
3838

39-
There are typically several types of plugins you can write:
39+
你可以撰写以下几种典型类型的插件:
4040

41-
1. Add one or more global methods. e.g. [vue-element](https://github.com/vuejs/vue-element)
42-
2. Add one or more global assets: directives/filters/transitions etc. e.g. [vue-touch](https://github.com/vuejs/vue-touch)
43-
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.
41+
1. 添加一个或几个全局方法。比如 [vue-element](https://github.com/vuejs/vue-element)
42+
2. 添加一个或几个全局资源:指令、过滤器、过渡效果等。比如 [vue-touch](https://github.com/vuejs/vue-touch)
43+
3. 通过绑定到 `Vue.prototype` 的方式添加一些 Vue 实例方法。这里有个约定,就是 Vue 的实例方法应该带有 `$` 前缀,这样就不会和用户的数据和方法产生冲突了。
4444

4545
``` js
4646
exports.install = function (Vue, options) {
@@ -50,27 +50,27 @@ exports.install = function (Vue, options) {
5050
}
5151
```
5252

53-
### Using a Plugin
53+
### 使用插件
5454

55-
Assuming using a CommonJS build system:
55+
假设我们使用的构建系统是 CommonJS,则:
5656

5757
``` js
5858
var vueTouch = require('vue-touch')
5959
// use the plugin globally
6060
Vue.use(vueTouch)
6161
```
6262

63-
You can also pass in additional options to the plugin:
63+
你也可以向插件里传递额外的选项:
6464

6565
```js
6666
Vue.use('my-plugin', {
6767
/* pass in additional options */
6868
})
6969
```
7070

71-
## Existing Tools
71+
## 现有的工具
7272

73-
- [vue-devtools](https://github.com/vuejs/vue-devtools): A Chrome devtools extension for debugging Vue.js applications.
74-
- [vue-touch](https://github.com/vuejs/vue-touch): Add touch-gesture directives using Hammer.js.
75-
- [vue-element](https://github.com/vuejs/vue-element): Register Custom Elements with Vue.js.
76-
- [List of User Contributed Tools](https://github.com/yyx990803/vue/wiki/User-Contributed-Components-&-Tools)
73+
- [vue-devtools](https://github.com/vuejs/vue-devtools):一个用来 debug Vue.js 应用程序的 Chrome 开发者工具扩展。
74+
- [vue-touch](https://github.com/vuejs/vue-touch):添加基于 Hammer.js 的触摸手势的指令。
75+
- [vue-element](https://github.com/vuejs/vue-element): Vue.js 注册 Custom Elements。
76+
- [用户贡献的工具列表](https://github.com/yyx990803/vue/wiki/User-Contributed-Components-&-Tools)

0 commit comments

Comments
 (0)