diff --git a/README.md b/README.md index 3f866306b7..088a38e5a9 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,163 @@ -# vue.js 2.0 正式版 中文翻译文档(正在进行中...) http://vuefe.cn +## vue.js 2.0 中文文档 http://vuefe.cn -> 基于 hexo && vuejs.org -> 求小伙伴共同翻译,有兴趣加qq 315129552 +>(即将完成 - 急需校对) -- 中文翻译分支 2.0-cn +## 贡献要求 -## 开发 +### 参与: -``` -$ npm install -g hexo-cli -$ npm install -$ hexo server -``` +- 加群参与 `42744737` +- [发布网址:vuefe.cn](http://vuefe.cn/) +- [翻译仓库](https://github.com/vuefe/vuejs.org),中文翻译分支 2.0-cn +- [基础指引](https://github.com/vuefe/vuejs.org/wiki/%E5%85%B3%E4%BA%8E%E7%BF%BB%E8%AF%91---%E5%9F%BA%E7%A1%80%E6%8C%87%E5%BC%95) +- 参与API翻译:https://github.com/vuefe/vuejs.org/issues/44 +- 参与Guide校对:https://github.com/vuefe/vuejs.org/issues/77 +- 提出建议:https://github.com/vuefe/vuejs.org/issues/48 +- 如果你看到错别字、漏译、错译,请直接提交 pr + ([帮助](https://help.github.com/articles/using-pull-requests/))。 +- 如果你看到网站问题,或者创建一个 issue,或者直接提交 pr。 +- 如果你对已有翻译有异议,建议创建一个 issue 讨论。 +- 如果你想修改英文内容,请去 [vuejs.org 项目][vuejs.org]。 +- 如果你想求教 Vue.js 使用问题,请去[论坛][forum]。 +- 如果你遇到 Vue.js 的问题,请去 [vue 项目][vue], + 创建 issue 并提供演示。可以在 JSBin, JSFiddle, Codepen 等网站创建演示。 + +### 翻译要求 + +- 保持一致,清晰 +- 汉字,字母,数字等之间以一个空格隔开。 +- 中文使用中文符号,英文使用英文符号。 +- 专有词注意大小写,如 HTML,CSS,JavaScript。 +- 术语与已有译文保持一致,如果有异议请先在 issue 中讨论。 +- 代码只翻译注释。 +- 标题会转化为链接,文档其它地方可能会用到,所以标题应尽量简短, + 在修改标题时搜索一下它是否还用在其它地方。 + 同样的,在修改文档内链接时也应搜索一下。 +- 校对后对应修改提交合并请求 + +### 统一固定词汇翻译 + +- Type => 类型 +- See also => 另见 +- Details => 详细 +- Options => 选项 +- Example => 示例 +- Restriction => 限制 +- default => 默认值 +- prop => 特性(是指 一个 API 时候,不要翻译成中文) +- attribute => 特性 +- transition => 过渡 + +### 术语翻译对照 -Start a dev server at `localhost:4000` +- attribute 特性 +- transition 过渡 -## merge +### 不翻译的术语 -- 翻译完 pull request 到 2.0-cn 分支 合并 +- getter +- setter +- prop(指API时) -## 发布 +### 认领说明 -> 预先添加git ssh +- 参与前,请在对应issue认领 +- 认领格式 : + - 未完成 + - [ ] 我校对 + `文档序号 ` +- markdown语法 - 示例 + +```markdown +- [ ] 我xx `1` ``` -hexo g -hexo d + + - 完成后,打钩表示完成,并附带 发起的合并请求链接 + - [x] 我校对 + `文档序号 ` + https://github.com/vuefe/vuejs.org/pull/65 (发起的合并请求链接) + +- markdown语法 - 示例 + +```markdown +- [x] 我xx + `1 ` https://github.com/vuefe/vuejs.org/pull/65 (发起的合并请求链接) ``` -## 当前说明(2016.09.26) +- 支持多人协作翻译,冲突可以解决,认领过的,如果你觉着他太慢,可以再次认领,加速翻译,知道大家都是牺牲业余时间来贡献,所以慢也是可以理解的,慢就需要大家一起帮帮忙了!谢谢。 + + +## Guide 翻译贡献 + +### Essentials 基础 + +序号 | 是否完成 | 对应文档文件名 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------- | ------------- | --- | --- | --- | --- +1 | 是 | installation.md | 安装 | [dingyiming](https://github.com/dingyiming) | +2 | 是 | index.md | 介绍 | [hijiangtao](https://github.com/hijiangtao) | +3 | 是 | instance.md | 实例 | [dingyiming](https://github.com/dingyiming) | +4 | 是 | syntax.md | 模板语法 | [daix6](https://github.com/daix6) | +5 | 是 | computed.md | 计算属 性 | [dingyiming](https://github.com/dingyiming) | +6 | 是 | class-and-style.md | Class 与 Style 绑定 | [595074187](https://github.com/595074187) | +7 | 是 | conditional.md | 条件渲染 | [dingyiming](https://github.com/dingyiming) | +8 | 是 | list.md | 列表渲染 | [tingtien](https://github.com/tingtien) | +9 | 是 | events.md | 事件处理器 | [dingyiming](https://github.com/dingyiming) | +10 | 是 | forms.md | 表单控件绑定 | [dingyiming](https://github.com/dingyiming) | +11 | 是 | components.md | 组件 | [ezreally](https://github.com/ezreally) | + +### Advanced 进阶 + +序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 校对贡献者 +----- | ------- | ------------- | --- | --- | --- | --- +12 | 是 | transitions.md | 过渡: 进入, 离开, 和 列表 | [awe](https://github.com/hilongjw) | +13 | 是 | transitioning-state.md | 过渡状态 | [awe](https://github.com/hilongjw) | +14 | 是 | render-function.md | Render 函数 | [awe](https://github.com/hilongjw) | +15 | 是 | reactivity.md | 深入响应式原理 | [veaba](https://github.com/veaba) | +16 | 是 | custom-directive.md | 自定义指令 | [harrytospring](https://github.com/harrytospring) | +17 | 是 | mixins.md | 混合 | [harrytospring](https://github.com/harrytospring) | +18 | 是 | plugins.md | 插件 | [hgcoder](https://github.com/hgcoder) | +19 | 是 | single-file-components.md | 单文件组件 | [ATLgo](https://github.com/ATLgo) | +20 | 是 | routing.md | 路由 | [dingyiming](https://github.com/dingyiming) | +21 | 是 | state-management.md | 状态管理 | [dear-lizhihua](https://github.com/dear-lizhihua) | +22 | 是 | unit-testing.md | 单元测试 | [70data](https://github.com/70data) | +23 | 是 | ssr.md | 服务端渲染 | [dingyiming](https://github.com/dingyiming)| + +### Migration 迁移 + +序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 校对贡献者 +----- | ------- | ------------- | --- | --- | --- +24 | 是 | migration.md | 1.x迁移 | [harrytospring](https://github.com/harrytospring) | +27 | 是 | migration-vue-router.md | vue-router 0.7.x 迁移 | [forzajuve10](https://github.com/forzajuve10) | + +### Meta 更多 + +序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 校对贡献者 +----- | ------- | ------------- | --- | --- | --- +25 | 是 | comparison.md | 对比其他框架 | [yongbolv](https://github.com/yongbolv) | +26 | 是 | join.md | 加入Vue.js社区 | [daix6](https://github.com/daix6) | + + +## API翻译贡献 + +序号 | 是否完成 | 对应小节名称 | 中文标题 | 贡献者 | 校对贡献者 +----- | ------- | ------------- | --- | --- | --- +1 | 是 | Global Config | 全局配置 | @dear-lizhihua | +2 | 是 | Global API | 全局API | @dear-lizhihua | +3 | 是 | Options / Data | 选项 / 数据 | @dear-lizhihua | +4 | 是 | Options / DOM | 选项 / DOM | @ATLgo | +5 | 是 | Options / Lifecycle Hooks | 选项 / 生命周期钩子 | @ATLgo | +6 | 是 | Options / Assets | 选项 / 资源 | @dingyiming | +7 | 是 | Options / Misc | 选项 / 杂项 | @dingyiming | +8 | 是 | Instance Properties | 实例属性 | @coolzjy | +9 | 是 | Instance Methods / Data | 实例方法 / 数据 | @dingyiming | +10 | 是 | Instance Methods / Events | 实例方法 / 事件 | @mlyknown | +11 | 是 | Instance Methods / Lifecycle | 实例方法 / 生命周期 | @mlyknown | +12 | 是 | Directives | 指令| @dingyiming | +13 | 是 | Special Attributes | 特殊元素 | @70data | +14 | 是 | Built-In Components | 内置的组件 | @dear-lizhihua | +15 | 是 | VNode Interface | VNode接口 | @70data | +16 | 是 | Server-Side Rendering | 服务端渲染| @70data | + +## 示例翻译 + +贡献者 : [lindazhang102](https://github.com/lindazhang102) + -* 基于hexo 和vuejs.org源码 -* 翻译有些滞后,刚刚更新,希望有兴趣的小伙伴直接找我,共勉 -* 文段中英文字母与中文用空一格做间隔,有助于阅读 -* 请尽量对照 vuejs 官方 1.0 中文文档进行翻译,也可以即时看出vue1和vue2直接的区别 -* 导航上 添加了 更新 模块,用于链接到github的 release信息,后面希望单独把changelog放到 /changelog中跟进翻译每次的版本更新内容 -* (畅想:加入热点标记功能 - 点击热点新建github 对应 issue ,话题链接 / 增强文档交互即时纠错) -* (畅想: 首页加入弹幕交互功能) -* (畅想: 添加hacknews-vue2案例解析 以及更多自定义案例解析) +## 感谢所有参与翻译的朋友们! \ No newline at end of file diff --git a/_config.yml b/_config.yml index 7ce6c2a161..c8bb955748 100644 --- a/_config.yml +++ b/_config.yml @@ -8,7 +8,7 @@ subtitle: description: "Reactive Components for Modern Web Interfaces" author: Evan You email: -language: +language: zh-CN # URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' diff --git a/src/about/guide.md b/src/about/guide.md index 79d4a353b2..2a80f884a8 100644 --- a/src/about/guide.md +++ b/src/about/guide.md @@ -1,62 +1,91 @@ --- title: 参与指南 type: about -order: 2 +order: 1 --- -- 加QQ群参与翻译: `427447379` -- [翻译Guide认领](https://github.com/vuefe/vuejs.org/issues/1) -- [翻译指引](https://github.com/vuefe/vuejs.org/issues/25) - -## 翻译进度 - -> 原文地址:http://vuejs.org/guide/ -> 仓库:https://github.com/vuefe/vuejs.org - -### 说明 - -- 翻译前,请在此回复认领 -- 认领格式 :` 我翻译 + 文档序号` 即可 - -## 以下所有文档所在目录为 `src/guide/xxx.md` - -### Essentials 基础 - -序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 认领者 ------ | ------- | ------------- | --- | --- | --- -1 | 是 | installation.md | 安装 | @dingyiming | - -2 | 否 | index.md | 介绍 | | @dingyiming -3 | 是 | instance.md | 实例 | @dingyiming | - -4 | × | syntax.md | 模板语法 | | | -5 | 是 | computed.md | 计算属性 | @dingyiming | - -6 | × | class-and-style.md | Class 与 Style 绑定 | | -7 | 是 | conditional.md | 条件渲染 | @dingyiming | - -8 | 是 | list.md | 列表渲染 | @tingtien | @tingtien -9 | 是 | events.md | 事件处理器 | @dingyiming | - -10 | 是 | forms.md | 表单控件绑定 | @dingyiming | - -11 | × | components.md | 组件 | | @ezreally - -### Advanced 进阶 - -序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 认领者 ------ | ------- | ------------- | --- | --- | --- -12 | 是 | transitions.md | 过渡: 进入, 离开, 和 列表 | @awe | @awe -13 | 是 | transitioning-state.md | 过渡状态 | @awe | @awe -14 | 是 | render-function.md | Render 函数 | @awe | @awe -15 | x | reactivity.md | 深入响应式原理 | | @veaba -16 | 是 | custom-directive.md | 自定义指令 | @harrytospring | @harrytospring -17 | 是 | mixins.md | 混合 | @harrytospring | @harrytospring -18 | x | plugins.md | 插件 | | @hgcoder -19 | x | single-file-components.md | 单文件组件 | | -20 | 是 | routing.md | 路由 | @dingyiming | @dingyiming -21 | x | state-management.md | 状态管理 | | -22 | x | unit-testing.md | 单元测试 | | @70data -23 | 是 | ssr.md | 服务端渲染 | @dingyiming | @dingyiming -24 | x | migration.md | 1.x迁移 | | @harrytospring - -### Meta 更多 - -序号 | 是否完成 | 对应文档文件名 | 中文标题 | 贡献者 | 认领者 ------ | ------- | ------------- | --- | --- | --- -25 | x | comparison.md | 对比其他框架 | | @yongbolv @daix6 -26 | x | join.md | 加入Vue.js社区 | | @daix6 +> 目前急需校对 + + +## 参与要求 + +### 参与: + +> 参与请阅读 [翻译规范](https://github.com/vuefe/vuejs.org/wiki/%E7%BF%BB%E8%AF%91%E8%A7%84%E8%8C%83) + +- 加群参与 `42744737` +- [发布网址:vuefe.cn](http://vuefe.cn/) +- [翻译仓库](https://github.com/vuefe/vuejs.org) ,中文翻译分支 2.0-cn +- [基础指引](https://github.com/vuefe/vuejs.org/wiki/%E5%85%B3%E4%BA%8E%E7%BF%BB%E8%AF%91---%E5%9F%BA%E7%A1%80%E6%8C%87%E5%BC%95) +- 参与API翻译:https://github.com/vuefe/vuejs.org/issues/44 +- 参与Guide校对:https://github.com/vuefe/vuejs.org/issues/77 +- 提出建议:https://github.com/vuefe/vuejs.org/issues/48 +- 如果你看到错别字、漏译、错译,请直接提交 pr + ([帮助](https://help.github.com/articles/using-pull-requests/))。 +- 如果你看到网站问题,或者创建一个 issue,或者直接提交 pr。 +- 如果你对已有翻译有异议,建议创建一个 issue 讨论。 +- 如果你想修改英文内容,请去 [vuejs.org 项目][vuejs.org]。 +- 如果你想求教 Vue.js 使用问题,请去[论坛][forum]。 +- 如果你遇到 Vue.js 的问题,请去 [vue 项目][vue], + 创建 issue 并提供演示。可以在 JSBin, JSFiddle, Codepen 等网站创建演示。 + +### 翻译要求 + +- 保持一致,清晰 +- 汉字,字母,数字等之间以一个空格隔开。 +- 中文使用中文符号,英文使用英文符号。 +- 专有词注意大小写,如 HTML,CSS,JavaScript。 +- 术语与已有译文保持一致,如果有异议请先在 issue 中讨论。 +- 代码只翻译注释。 +- 标题会转化为链接,文档其它地方可能会用到,所以标题应尽量简短, + 在修改标题时搜索一下它是否还用在其它地方。 + 同样的,在修改文档内链接时也应搜索一下。 +- 校对后对应修改提交合并请求 + +### 统一固定词汇翻译 + +- Type => 类型 +- See also => 另见 +- Details => 详细 +- Options => 选项 +- Example => 示例 +- Restriction => 限制 +- default => 默认值 +- prop => 特性(是指 一个 API 时候,不要翻译成中文) +- attribute => 特性 +- transition => 过渡 + +### 术语翻译对照 + +- attribute 特性 +- transition 过渡 + +### 不翻译的术语 + +- getter +- setter +- prop(指API时) + +### 认领说明 + +- 参与前,请在对应issue认领 +- 认领格式 : + - 未完成 + - [ ] 我校对 + `文档序号 ` + +- markdown语法 - 示例 + +```markdown +- [ ] 我xx `1` +``` + + - 完成后,打钩表示完成,并附带 发起的合并请求链接 + - [x] 我校对 + `文档序号 ` + https://github.com/vuefe/vuejs.org/pull/65 (发起的合并请求链接) + +- markdown语法 - 示例 + +```markdown +- [x] 我xx + `1 ` https://github.com/vuefe/vuejs.org/pull/65 (发起的合并请求链接) +``` + +- 支持多人协作翻译,冲突可以解决,认领过的,如果你觉着他太慢,可以再次认领,加速翻译,知道大家都是牺牲业余时间来贡献,所以慢也是可以理解的,慢就需要大家一起帮帮忙了!谢谢。 diff --git a/src/about/index.md b/src/about/index.md index 83e2b741fc..b0f151f38e 100644 --- a/src/about/index.md +++ b/src/about/index.md @@ -1,8 +1,88 @@ --- -title: 关于翻译 +title: 贡献者 type: about -order: 1 +order: 0 --- -- 加QQ群参与翻译: `427447379` -- [翻译Guide认领](https://github.com/vuefe/vuejs.org/issues/1) \ No newline at end of file +## 目前任务 + +- [vue 2.0 - Guide 翻译校对 (进度 / 认领)](https://github.com/vuefe/vuejs.org/issues/77) +- [vue 2.0 - API 翻译校对 (进度 / 认领)](https://github.com/vuefe/vuejs.org/issues/119) +- [vuex 2.0 - 文档翻译 (进度 / 认领)](https://github.com/vuefe/vuejs.org/issues/124) + +## Guide 翻译贡献 + +### Essentials 基础 + +序号 | 对应文档文件名 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------------- | --- | --- | --- | --- +1 | installation.md | 安装 | [dingyiming](https://github.com/dingyiming) | +2 | index.md | 介绍 | [hijiangtao](https://github.com/hijiangtao) | +3 | instance.md | 实例 | [dingyiming](https://github.com/dingyiming) | +4 | syntax.md | 模板语法 | [daix6](https://github.com/daix6) | +5 | computed.md | 计算属 性 | [dingyiming](https://github.com/dingyiming) | +6 | class-and-style.md | Class 与 Style 绑定 | [595074187](https://github.com/595074187) | +7 | conditional.md | 条件渲染 | [dingyiming](https://github.com/dingyiming) | +8 | list.md | 列表渲染 | [tingtien](https://github.com/tingtien) | +9 | events.md | 事件处理器 | [dingyiming](https://github.com/dingyiming) | +10 | forms.md | 表单控件绑定 | [dingyiming](https://github.com/dingyiming) | +11 | components.md | 组件 | [ezreally](https://github.com/ezreally) | + +### Advanced 进阶 + +序号 | 对应文档文件名 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------------- | --- | --- | --- +12 | transitions.md | 过渡: 进入, 离开, 和 列表 | [awe](https://github.com/hilongjw) | +13 | transitioning-state.md | 过渡状态 | [awe](https://github.com/hilongjw) | +14 | render-function.md | Render 函数 | [awe](https://github.com/hilongjw) | +15 | reactivity.md | 深入响应式原理 | [veaba](https://github.com/veaba) | +16 | custom-directive.md | 自定义指令 | [harrytospring](https://github.com/harrytospring) | +17 | mixins.md | 混合 | [harrytospring](https://github.com/harrytospring) | +18 | plugins.md | 插件 | [hgcoder](https://github.com/hgcoder) | +19 | single-file-components.md | 单文件组件 | [ATLgo](https://github.com/ATLgo) | +20 | routing.md | 路由 | [dingyiming](https://github.com/dingyiming) | +21 | state-management.md | 状态管理 | [dear-lizhihua](https://github.com/dear-lizhihua) | +22 | unit-testing.md | 单元测试 | [70data](https://github.com/70data) | +23 | ssr.md | 服务端渲染 | [dingyiming](https://github.com/dingyiming) | + +### Migration 迁移 + +序号 | 对应文档文件名 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------------- | --- | --- | --- +24 | migration.md | 1.x迁移 | [harrytospring](https://github.com/harrytospring) | +27 | migration-vue-router.md | vue-router 0.7.x 迁移 | [forzajuve10](https://github.com/forzajuve10) | + +### Meta 更多 + +序号 | | 对应文档文件名 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------------- | --- | --- | --- | --- +25 | comparison.md | 对比其他框架 | [yongbolv](https://github.com/yongbolv) | +26 | join.md | 加入Vue.js社区 | [daix6](https://github.com/daix6) | + +## API翻译贡献 + +序号 | 对应小节名称 | 中文标题 | 翻译贡献者 | 校对贡献者 +----- | ------------- | --- | --- | --- +1 | Global Config | 全局配置 | [dear-lizhihua](https://github.com/dear-lizhihua) | +2 | Global API | 全局API | [dear-lizhihua](https://github.com/dear-lizhihua) | +3 | Options / Data | 选项 / 数据 | [dear-lizhihua](https://github.com/dear-lizhihua) | +4 | Options / DOM | 选项 / DOM | [ATLgo](https://github.com/ATLgo) | +5 | Options / Lifecycle Hooks | 选项 / 生命周期钩子 | [ATLgo](https://github.com/ATLgo) | +6 | Options / Assets | 选项 / 资源 | [dingyiming](https://github.com/dingyiming) | +7 | Options / Misc | 选项 / 杂项 | [dingyiming](https://github.com/dingyiming) | +8 | Instance Properties | 实例属性 | [coolzjy](https://github.com/coolzjy) | +9 | Instance Methods / Data | 实例方法 / 数据 | [dingyiming](https://github.com/dingyiming) | +10 | Instance Methods / Events | 实例方法 / 事件 | [mlyknown](https://github.com/mlyknown) | +11 | Instance Methods / Lifecycle | 实例方法 / 生命周期 | [mlyknown](https://github.com/mlyknown) | +12 | Directives | 指令| [dingyiming](https://github.com/dingyiming) | +13 | Special Attributes | 特殊元素 | [70data](https://github.com/70data) | +14 | Built-In Components | 内置的组件 | [dear-lizhihua](https://github.com/dear-lizhihua) | +15 | VNode Interface | VNode接口 | [70data](https://github.com/70data) | +16 | Server-Side Rendering | 服务端渲染| [70data](https://github.com/70data)| + +## 示例翻译 + +翻译贡献者 : [lindazhang102](https://github.com/lindazhang102) + + +## 感谢所有参与翻译的朋友们! \ No newline at end of file diff --git a/src/api/index.md b/src/api/index.md index 2f6bfc908a..368bf46435 100644 --- a/src/api/index.md +++ b/src/api/index.md @@ -2,31 +2,31 @@ type: api --- -## Global Config +## 全局配置 -`Vue.config` is an object containing Vue's global configurations. You can modify its properties listed below before bootstrapping your application: +`Vue.config` is 是一个对象,包含 Vue 的全局配置。可以在启动应用之前修改下列属性: ### silent -- **Type:** `boolean` +- **类型:** `boolean` -- **Default:** `false` +- **默认值:** `false` -- **Usage:** +- **用法:** ``` js Vue.config.silent = true ``` - Suppress all Vue logs and warnings. + 取消 Vue 所有的日志与警告。 ### optionMergeStrategies -- **Type:** `{ [key: string]: Function }` +- **类型:** `{ [key: string]: Function }` -- **Default:** `{}` +- **默认值:** `{}` -- **Usage:** +- **用法:** ``` js Vue.config.optionMergeStrategies._my_option = function (parent, child, vm) { @@ -40,34 +40,34 @@ type: api // Profile.options._my_option = 2 ``` - Define custom merging strategies for options. + 自定义选项的混合策略。 - The merge strategy receives the value of that option defined on the parent and child instances as the first and second arguments, respectively. The context Vue instance is passed as the third argument. + 合并策略函数接收定义在父实例和子实例上的 option,分别作为第一个和第二个参数的值,Vue实例上下文被作为第三个参数传入。 -- **See also**: [Custom Option Merging Strategies](/guide/mixins.html#Custom-Option-Merge-Strategies) +- **参考**: [自定义选项的混合策略](/guide/mixins.html#Custom-Option-Merge-Strategies) ### devtools -- **Type:** `boolean` +- **类型:** `boolean` -- **Default:** `true` (`false` in production builds) +- **默认值:** `true` (生产版为 `false`) -- **Usage:** +- **用法:** ``` js - // make sure to set this synchronously immediately after loading Vue + // 务必在加载 Vue 之后,立即同步设置以下内容 Vue.config.devtools = true ``` - Configure whether to allow [vue-devtools](https://github.com/vuejs/vue-devtools) inspection. This option's default value is `true` in development builds and `false` in production builds. You can set it to `true` to enable inspection for production builds. + 配置是否允许 [vue-devtools](https://github.com/vuejs/vue-devtools) 检查代码。开发版本默认为 `true`,生产版本默认为 `false`。生产版本设为 `true` 可以启用检查。 ### errorHandler -- **Type:** `Function` +- **类型:** `Function` -- **Default:** Error is thrown in place +- **默认值:** 默认抛出错误 -- **Usage:** +- **用法:** ``` js Vue.config.errorHandler = function (err, vm) { @@ -75,41 +75,41 @@ type: api } ``` - Assign a handler for uncaught errors during component render and watchers. The handler gets called with the error and the Vue instance. + 指定组件的渲染和观察期间未捕获错误的处理函数。处理函数被调用时,可获取错误信息和 Vue 实例。 ### keyCodes -- **Type:** `{ [key: string]: number }` +- **类型:** `{ [key: string]: number }` -- **Default:** `{}` +- **默认值:** `{}` -- **Usage:** +- **用法:** ``` js Vue.config.keyCodes = { esc: 27 } ``` - Define custom key aliases for v-on. + 自定义 v-on 键位别名。 -## Global API +## 全局 API
{{firstName}} {{lastName}} aka {{alias}}
', data: function () { @@ -120,82 +120,82 @@ type: api } } }) - // create an instance of Profile and mount it on an element + // 创建 Profile 实例,并挂载到一个元素上。 new Profile().$mount('#mount-point') ``` - Will result in: + 结果如下: ``` htmlWalter White aka Heisenberg
``` -- **See also:** [Components](/guide/components.html) +- **参考:** [组件](/guide/components.html)Note that __you should not use an arrow function with the `data` property__ (e.g. `data: () => { return { a: this.myProp }}`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.myProp` will be undefined.
+注意,__不应该对 `data` 属性使用箭头函数__ (例如`data: () => { return { a: this.myProp }}`)。理由是箭头函数绑定了父级作用域的上下文,所以 this 将不会按照期望指向 Vue 实例,`this.myProp` 将是 undefined。
-- **See also:** [Reactivity in Depth](/guide/reactivity.html) +- **另见:** [深入响应式原理](/guide/reactivity.html) ### props -- **Type:** `ArrayNote that __you should not use an arrow function to define a computed property__ (e.g. `aDouble: () => this.a * 2`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.
+注意,__不应该使用箭头函数来定义计算属性函数__ (例如 `aDouble: () => this.a * 2`)。理由是箭头函数绑定了父级作用域的上下文,所以 `this` 将不会按照期望指向 Vue 实例,`this.a` 将是 undefined。
- Computed properties are cached, and only re-computed on reactive dependency changes. + 计算属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算。 -- **Example:** +- **示例:** ```js var vm = new Vue({ data: { a: 1 }, computed: { - // get only, just need a function + // 仅读取,值只须为函数 aDouble: function () { return this.a * 2 }, - // both get and set + // 读取和设置 aPlus: { get: function () { return this.a + 1 @@ -451,20 +453,20 @@ type: api vm.aDouble // -> 4 ``` -- **See also:** - - [Computed Properties](/guide/computed.html) +- **另见:** + - [计算属性](/guide/computed.html) ### methods -- **Type:** `{ [key: string]: Function }` +- **类型:** `{ [key: string]: Function }` -- **Details:** +- **详细:** - Methods to be mixed into the Vue instance. You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the Vue instance. + methods 将被混入到 Vue 实例中。可以直接通过 VM 实例访问这些方法,或者在指令表达式中使用。方法中的 `this` 自动绑定为 Vue 实例。 -Note that __you should not use an arrow function to define a method__ (e.g. `plus: () => this.a++`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.
+注意,__不应该使用箭头函数来定义 method 函数__ (例如 `plus: () => this.a++`)。理由是箭头函数绑定了父级作用域的上下文,所以 `this` 将不会按照期望指向 Vue 实例,`this.a` 将是 undefined。
-- **Example:** +- **示例:** ```js var vm = new Vue({ @@ -479,17 +481,17 @@ type: api vm.a // 2 ``` -- **See also:** [Methods and Event Handling](/guide/events.html) +- **另见:** [方法与事件处理器](/guide/events.html) ### watch -- **Type:** `{ [key: string]: string | Function | Object }` +- **类型:** `{ [key: string]: string | Function | Object }` -- **Details:** +- **详细:** - An object where keys are expressions to watch and values are the corresponding callbacks. The value can also be a string of a method name, or an Object that contains additional options. The Vue instance will call `$watch()` for each entry in the object at instantiation. + 一个对象,键是需要观察的表达式,值是对应回调函数。值也可以是方法名,或者包含选项的对象。Vue 实例将会在实例化时调用 `$watch()`,遍历 watch 对象的每一个属性。 -- **Example:** +- **示例:** ``` js var vm = new Vue({ @@ -502,9 +504,9 @@ type: api a: function (val, oldVal) { console.log('new: %s, old: %s', val, oldVal) }, - // string method name + // 方法名 b: 'someMethod', - // deep watcher + // 深度 watcher c: { handler: function (val, oldVal) { /* ... */ }, deep: true @@ -514,9 +516,9 @@ type: api vm.a = 2 // -> new: 2, old: 1 ``` -Note that __you should not use an arrow function to define a watcher__ (e.g. `searchQuery: newValue => this.updateAutocomplete(newValue)`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.updateAutocomplete` will be undefined.
+注意,__不应该使用箭头函数来定义 watcher 函数__ (例如 `searchQuery: newValue => this.updateAutocomplete(newValue)`)。理由是箭头函数绑定了父级作用域的上下文,所以 `this` 将不会按照期望指向 Vue 实例,`this.updateAutocomplete` 将是 undefined。
-- **See also:** [Instance Methods - vm.$watch](#vm-watch) +- **另见:** [实例方法 - vm.$watch](#vm-watch) ## 选项 / DOM @@ -695,65 +697,64 @@ type: api - **另见:** [生命周期图示](/guide/instance.html#Lifecycle-Diagram) -## Options / Assets +## 选项 / 资源 ### directives -- **Type:** `Object` +- **类型:** `Object` -- **Details:** +- **详细:** - A hash of directives to be made available to the Vue instance. +一个 用于 Vue 实例 的带 hash 的指令。 -- **See also:** - - [Custom Directives](/guide/custom-directive.html) - - [Assets Naming Convention](/guide/components.html#Assets-Naming-Convention) +- **另见:** + - [自定义指令](/guide/custom-directive.html) + - [资源命名约定](/guide/components.html#Assets-Naming-Convention) ### filters -- **Type:** `Object` +- **类型:** `Object` -- **Details:** +- **详细:** - A hash of filters to be made available to the Vue instance. +一个 用于 Vue 实例 的带 hash 的过滤器。 -- **See also:** +- **另见:** - [`Vue.filter`](#Vue-filter) ### components -- **Type:** `Object` +- **类型:** `Object` -- **Details:** +- **详细:** - A hash of components to be made available to the Vue instance. +一个 用于 Vue 实例 的带 hash 的组件。 -- **See also:** - - [Components](/guide/components.html) +- **另见:** + - [组件](/guide/components.html) -## Options / Misc +## 选项 / 杂项 ### parent -- **Type:** `Vue instance` +- **类型:** `Vue instance` -- **Details:** +- **详细:** - 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. + 指定实例的父实例,在两者之间建立父子关系。子实例可以用 `this.$parent` 访问父实例,子实例被推入父实例的 `$children` 数组中。 -Use `$parent` and `$children` sparringly - they mostly serve as an escape-hatch. Prefer using props and events for parent-child communication.
+同时使用 `$parent` 和 `$children` 有冲突 - 他们作为同一个入口 。更推荐用 props 和 events 实现父子组件通信
### mixins -- **Type:** `Array