diff --git a/README.md b/README.md index 4ef988a0d8..3f866306b7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,40 @@ -# vuejs.org +# vue.js 2.0 正式版 中文翻译文档(正在进行中...) http://vuefe.cn -This site is built with [hexo](http://hexo.io/). Site content is written in Markdown format located in `src`. Pull requests welcome! +> 基于 hexo && vuejs.org +> 求小伙伴共同翻译,有兴趣加qq 315129552 -## Developing +- 中文翻译分支 2.0-cn -Start a dev server at `localhost:4000`: +## 开发 ``` $ npm install -g hexo-cli $ npm install $ hexo server ``` + +Start a dev server at `localhost:4000` + +## merge + +- 翻译完 pull request 到 2.0-cn 分支 合并 + +## 发布 + +> 预先添加git ssh + +``` +hexo g +hexo d +``` + +## 当前说明(2016.09.26) + +* 基于hexo 和vuejs.org源码 +* 翻译有些滞后,刚刚更新,希望有兴趣的小伙伴直接找我,共勉 +* 文段中英文字母与中文用空一格做间隔,有助于阅读 +* 请尽量对照 vuejs 官方 1.0 中文文档进行翻译,也可以即时看出vue1和vue2直接的区别 +* 导航上 添加了 更新 模块,用于链接到github的 release信息,后面希望单独把changelog放到 /changelog中跟进翻译每次的版本更新内容 +* (畅想:加入热点标记功能 - 点击热点新建github 对应 issue ,话题链接 / 增强文档交互即时纠错) +* (畅想: 首页加入弹幕交互功能) +* (畅想: 添加hacknews-vue2案例解析 以及更多自定义案例解析) diff --git a/_config.yml b/_config.yml index 182ed390e0..7ce6c2a161 100644 --- a/_config.yml +++ b/_config.yml @@ -12,7 +12,7 @@ language: # URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' -url: http://vuejs.org +url: http://vuefe.cn root: / permalink: :year/:month/:day/:title/ tag_dir: tags @@ -97,7 +97,8 @@ markdown: ## Docs: http://zespia.tw/hexo/docs/deployment.html deploy: type: git - repository: git@github.com:vuejs/vuejs.org.git + repository: git@github.com:vuefe/vuefe.github.io.git + branch: master feed: type: atom diff --git a/package.json b/package.json index 4e94bc532a..4d767e0f17 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "version": "3.2.2" }, "dependencies": { + "hexo-browsersync": "^0.2.0", "hexo": "^3.2.2", "hexo-deployer-git": "0.1.0", "hexo-generator-archive": "^0.1.4", diff --git a/src/CNAME b/src/CNAME index 998cc417c8..ef5fa2c57b 100644 --- a/src/CNAME +++ b/src/CNAME @@ -1 +1 @@ -vuejs.org +vuefe.cn diff --git a/src/about/guide.md b/src/about/guide.md new file mode 100644 index 0000000000..79d4a353b2 --- /dev/null +++ b/src/about/guide.md @@ -0,0 +1,62 @@ +--- +title: 参与指南 +type: about +order: 2 +--- + +- 加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 diff --git a/src/about/index.md b/src/about/index.md new file mode 100644 index 0000000000..83e2b741fc --- /dev/null +++ b/src/about/index.md @@ -0,0 +1,8 @@ +--- +title: 关于翻译 +type: about +order: 1 +--- + +- 加QQ群参与翻译: `427447379` +- [翻译Guide认领](https://github.com/vuefe/vuejs.org/issues/1) \ No newline at end of file diff --git a/src/awesome/index.md b/src/awesome/index.md new file mode 100644 index 0000000000..812007f959 --- /dev/null +++ b/src/awesome/index.md @@ -0,0 +1,638 @@ +--- +title: 资源 +type: awesome +order: 0 +--- +
+
+
+
+
+
Ask a yes/no question: @@ -197,7 +202,7 @@ For example:
Ask a yes/no question: @@ -271,6 +277,7 @@ var watchExampleVM = new Vue({ answer: 'I cannot give you an answer until you ask a question!' }, watch: { + // whenever question changes, this function will run question: function (newQuestion) { this.answer = 'Waiting for you to stop typing...' this.getAnswer() @@ -293,6 +300,8 @@ var watchExampleVM = new Vue({ vm.answer = 'Error! Could not reach the API. ' + error }) }, + // This is the number of milliseconds we wait for the + // user to stop typing. 500 ) } @@ -300,6 +309,13 @@ var watchExampleVM = new Vue({ {% endraw %} -In this case, using the `watch` option allows us to perform an asynchronous operation (accessing an API), limit how often we perform that operation, and set intermediary states until we get a final answer. None of that would be possible with a computed property. +在这个示例中,使用`watch`的设置允许我们执行异步操作(访问一个接口),限制我们多久执行该操作,并在我们获取最终结果时立刻设置状态。这是计算属性无法做到的。 + +关于`watch` 选项,可看API文档[vm.$watch API](/api/#vm-watch)。 + +*** + +> 原文:http://rc.vuejs.org/guide/computed.html + +*** -In addition to the `watch` option, you can also use the imperative [vm.$watch API](/api/#vm-watch). diff --git a/src/guide/conditional.md b/src/guide/conditional.md index 7c8166aa59..abd3894453 100644 --- a/src/guide/conditional.md +++ b/src/guide/conditional.md @@ -1,36 +1,36 @@ --- -title: Conditional Rendering +title: 条件渲染 type: guide order: 7 --- ## v-if -In string templates, for example Handlebars, we would write a conditional block like this: +在字符串模板中,如 Handlebars,我们得像这样写一个条件块: ``` html - + {{#if ok}}
注意 `v-show` 不支持 `` 语法。
+ + +## v-else -You can use the `v-else` directive to indicate an "else block" for `v-if`: +可以用 `v-else` 指令给 `v-if` 或 `v-show` 添加一个 "else 块": ``` html这可能也是一个组件
``` -The difference is that an element with `v-show` will always be rendered and remain in the DOM; `v-show` simply toggles the `display` CSS property of the element. +用另一个 `v-show` 替换 `v-else`: + +```html +这可能也是一个组件
+``` -Note that `v-show` doesn't support the `` syntax, nor does it work with `v-else`.
+这样就可以达到 `v-if` 的效果。 ## v-if vs. v-show -`v-if` is "real" conditional rendering because it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created during toggles. +在切换 `v-if` 块时,Vue.js 有一个局部编译/卸载过程,因为 `v-if` 之中的模板也可能包括数据绑定或子组件。`v-if` 是真实的条件渲染,因为它会确保条件块在切换当中合适地销毁与重建条件块内的事件监听器和子组件。 + +`v-if` 也是**惰性的**:如果在初始渲染时条件为假,则什么也不做——在条件第一次变为真时才开始局部编译(编译会被缓存起来)。 + +相比之下,`v-show` 简单得多——元素始终被编译并保留,只是简单地基于 CSS 切换。 + +一般来说,`v-if` 有更高的切换消耗而 `v-show` 有更高的初始渲染消耗。因此,如果需要频繁切换 `v-show` 较好,如果在运行时条件不大可能改变 `v-if` 较好。 + -`v-if` is also **lazy**: if the condition is false on initial render, it will not do anything - the conditional block won't be rendered until the condition becomes true for the first time. +*** -In comparison, `v-show` is much simpler - the element is always rendered regardless of initial condition, with just simple CSS-based toggling. +> 原文:http://rc.vuejs.org/guide/conditional.html -Generally speaking, `v-if` has higher toggle costs while `v-show` has higher initial render costs. So prefer `v-show` if you need to toggle something very often, and prefer `v-if` if the condition is unlikely to change at runtime. +*** diff --git a/src/guide/custom-directive.md b/src/guide/custom-directive.md index 55bf700013..ed9fd28cd0 100644 --- a/src/guide/custom-directive.md +++ b/src/guide/custom-directive.md @@ -1,12 +1,12 @@ --- -title: Custom Directives +title: 自定义指令 type: guide order: 16 --- -## Intro +## 简介 -In addition to the default set of directives shipped in core (`v-model` and `v-show`), Vue also allows you to register your own custom directives. Note that in Vue 2.0, the primary form of code reuse and abstraction is components - however there may be cases where you just need some low-level DOM access on plain elements, and this is where custom directives would still be useful. An example would be focusing on an input element, like this one: +除了默认设置的核心指令(`v-model`和`v-show`),Vue也允许注册自定义指令。注意,在vue2.0里面,代码复用的主要形式和抽象是组件——然而,有的情况下,你仍然需要对纯DOM元素进行底层操作,这时候就会用到自定义指令。下面这个例子聚焦一个input元素,像这样: {% raw %}Apart from `el`, you should treat these arguments as read-only and never modify them. If you need to share information across hooks, it is recommended to do so through element's [dataset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset).
+除了 `el` 之外, 其它参数都应该是只读的,尽量不要修改他们。如果需要在钩子之间共享数据,建议通过元素的 [dataset] 来进行。(https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset).
-An example of a custom directive using some of these properties: +一个使用了这些参数的自定义钩子样例: ``` html @@ -138,19 +139,18 @@ new Vue({ {% endraw %} -## Function Shorthand +## 函数简写 -In many cases, you may want the same behavior on `bind` and `update`, but don't care about the other hooks. For example: +大多数情况下,只需要在 `bind` 和 `update` 钩子中做重复动作,而不关心其它钩子函数。可以这样写: ``` js Vue.directive('color-swatch', function (el, binding) { el.style.backgroundColor = binding.value }) ``` +## 对象常量 -## Object Literals - -If your directive needs multiple values, you can also pass in a JavaScript object literal. Remember, directives can take any valid JavaScript expression. +如果自定义指令需要复杂的值,也可以传递 javascript 对象。要知道,指令函数能够接受所有类型的 javascript 常量。 ``` html diff --git a/src/guide/events.md b/src/guide/events.md index 9b705db645..2937b3e9a1 100644 --- a/src/guide/events.md +++ b/src/guide/events.md @@ -1,19 +1,19 @@ --- -title: Event Handling +title: 事件处理器 type: guide order: 9 --- -## Listening to Events +## 监听事件 -We can use the `v-on` directive to listen to DOM events and run some JavaScript when they're triggered. +可以用 `v-on` 指令监听 DOM 事件来触发一些JavaScript代码。 -For example: +示例: ``` htmlThe button above has been clicked {{ counter }} times.
+ +这个按钮被点击了 {{ counter }} 次。
The button above has been clicked {{ counter }} times.
+ +这个按钮被点击了 {{ counter }} 次。
`v-model` doesn't care about the initial value provided to an input or a textarea. It will always treat the Vue instance data as the source of truth.
- -### Text +### 文本 ``` html @@ -32,7 +30,7 @@ new Vue({ {% endraw %} -### Multiline text +### 多行文本 ``` html Multiline message is: @@ -57,14 +55,9 @@ new Vue({ {% endraw %} +### 复选框 -{% raw %} -Interpolation on textareas (<textarea>{{text}}</textarea>
) won't work. Use v-model
instead.