Skip to content

Commit 0e96a0a

Browse files
authored
Merge pull request #204 from dear-lizhihua/2.0-cn
Migration from Vuex 0.6.x to 1.0
2 parents 6f7e6df + 96f8ddd commit 0e96a0a

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

src/guide/migration-vuex.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
---
2-
title: Migration from Vuex 0.6.x to 1.0
2+
title: Vuex 0.6.x 迁移到 1.0
33
type: guide
44
order: 27
55
---
66

7-
> Vuex 2.0 is released, but this guide only covers the migration to 1.0? Is that a typo? Also, it looks like Vuex 1.0 and 2.0 were released simultaneously. What's going on? Which one should I use and what's compatible with Vue 2.0?
7+
> Vuex 2.0 已经发布了,但是这份指南只涵盖迁移到 1.0?这是打错了吗?此外,似乎 Vuex 1.0 2.0 也同时发布。这是怎么回事?我该用哪一个并且哪一个兼容 Vue 2.0呢?
88
9-
Both Vuex 1.0 and 2.0:
9+
Vuex 1.0 2.0 如下:
1010

11-
- fully support both Vue 1.0 and 2.0
12-
- will be maintained for the forseeable future
11+
- 都完全支持 Vue 1.0 2.0
12+
- 将在可预见的未来保留支持
1313

14-
They have slightly different target users however.
14+
然而它们的目标用户稍微有所不同。
1515

16-
__Vuex 2.0__ is a radical redesign and simplification of the API, for those who are starting new projects or want to be on the cutting edge of client-side state management. __It is not covered by this migration guide__, so you should check out [the Vuex 2.0 docs](https://vuex.vuejs.org/en/index.html) if you'd like to learn more about it.
16+
__Vuex 2.0__ 从根本上重新设计并且提供简洁的 API,用于帮助正在开始一个新项目的用户,或想要用客户端状态管理前沿技术的用户。__此迁移指南不涵盖 Vuex 2.0 相关内容__,因此如果你想了解更多,请查阅 [Vuex 2.0 文档](https://vuex.vuejs.org/en/index.html)
1717

18-
__Vuex 1.0__ is mostly backwards-compatible, so requires very few changes to upgrade. It is recommended for those with large existing codebases or who just want the smoothest possible upgrade path to Vue 2.0. This guide is dedicated to facilitating that process, but only includes migration notes. For the complete usage guide, see [the Vuex 1.0 docs](https://github.com/vuejs/vuex/tree/1.0/docs/en).
18+
__Vuex 1.0__ 主要是向下兼容,所以升级只需要很小的改动。推荐拥有大量现存代码库的用户,或只想尽可能平滑升级 Vue 2.0 的用户。这份指南致力促进这一过程,但仅包括迁移说明。完整使用指南请查阅 [Vuex 1.0 文档](https://github.com/vuejs/vuex/tree/1.0/docs/en)
1919

20-
<p class="tip">The list of deprecations below should be relatively complete, but the migration helper is still being updated to catch them.</p>
20+
<p class="tip">下面列出的废弃内容相对完整,但是迁移工具还是会在升级时捕获它们。</p>
2121

22-
## `store.watch` with String Property Path <sup>deprecated</sup>
22+
## 传入字符串属性路径的 `store.watch` <sup>废弃</sup>
2323

24-
`store.watch` now only accept functions. So for example, you would have to replace:
24+
`store.watch` 现在只接受函数。因此,下面例子你需要替换:
2525

2626
``` js
2727
store.watch('user.notifications', callback)
2828
```
2929

30-
with:
30+
为:
3131

3232
``` js
3333
store.watch(
34-
// When the returned result changes...
34+
// 当返回结果改变...
3535
function (state) {
3636
return state.user.notifications
3737
},
38-
// Run this callback
38+
// 执行回调函数
3939
callback
4040
)
4141
```
4242

43-
This gives you more complete control over the reactive properties you'd like to watch.
43+
这帮助你更加完善的控制那些需要监听的响应式属性。
4444

4545
{% raw %}
4646
<div class="upgrade-path">
47-
<h4>Upgrade Path</h4>
48-
<p>Run the <a href="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of <code>store.watch</code> with a string as the first argument.</p>
47+
<h4>升级方法</h4>
48+
<p>在代码库运行<a href="https://github.com/vuejs/vue-migration-helper">迁移工具</a>,查找在 <code>store.watch</code> 中使用字符串作为第一个参数的事例。</p>
4949
</div>
5050
{% endraw %}
5151

52-
## Store's Event Emitter <sup>deprecated</sup>
52+
## Store 的事件触发器 <sup>废弃</sup>
5353

54-
The store instance no longer exposes the event emitter interface (`on`, `off`, `emit`). If you were previously using the store as a global event bus, [see this section](http://vuejs.org/guide/migration.html#dispatch-and-broadcast-deprecated) for migration instructions.
54+
store 实例不再暴露事件触发器(event emitter)接口(`on`, `off`, `emit`)。如果你之前使用 store 作为全局的 event bus,迁移说明相关内容请查阅[此章节](http://vuejs.org/guide/migration.html#dispatch-and-broadcast-deprecated)
5555

56-
Instead of using this interface to watch events emitted by the store itself (e.g. `store.on('mutation', callback)`), a new method `store.subscribe` is introduced. Typical usage inside a plugin would be:
56+
为了替换正在使用观察 store 自身触发事件的这些接口,(例如:`store.on('mutation', callback)`),我们引入新的方法 `store.subscribe`。在插件中的典型使用方式如下:
5757

5858
``` js
5959
var myPlugin = store => {
@@ -64,18 +64,18 @@ var myPlugin = store => {
6464

6565
```
6666

67-
See example [the plugins docs](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md) for more info.
67+
更多信息请查阅[插件文档](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md)的示例。
6868

6969
{% raw %}
7070
<div class="upgrade-path">
71-
<h4>Upgrade Path</h4>
72-
<p>Run the <a href="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of <code>store.on</code>, <code>store.off</code>, and <code>store.emit</code>.</p>
71+
<h4>升级方式</h4>
72+
<p>在代码库运行<a href="https://github.com/vuejs/vue-migration-helper">迁移工具</a>,查找使用了 <code>store.on</code>, <code>store.off</code>, <code>store.emit</code> 的事例。</p>
7373
</div>
7474
{% endraw %}
7575

76-
## Middlewares <sup>deprecated</sup>
76+
## 中间件 <sup>废弃</sup>
7777

78-
Middlewares are replaced by plugins. A plugin is simply a function that receives the store as the only argument, and can listen to the mutation event on the store:
78+
中间件被替换为插件。插件是接收 store 作为仅有参数的基本函数,能够监听 store 中的 mutation 事件:
7979

8080
``` js
8181
const myPlugins = store => {
@@ -85,11 +85,11 @@ const myPlugins = store => {
8585
}
8686
```
8787

88-
For more details, see [the plugins docs](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md).
88+
更多详情, 请查阅 [插件文档](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md)
8989

9090
{% raw %}
9191
<div class="upgrade-path">
92-
<h4>Upgrade Path</h4>
93-
<p>Run the <a href="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of the <code>middlewares</code> option on a store.</p>
92+
<h4>升级方法</h4>
93+
<p>在代码库运行<a href="https://github.com/vuejs/vue-migration-helper">迁移工具</a>,查找使用了 <code>middlewares</code> 选项的事例。</p>
9494
</div>
9595
{% endraw %}

src/guide/migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Vue1.x 迁移
2+
title: Vue 1.x 迁移
33
type: guide
44
order: 25
55
---

src/vuex/actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ actions: {
4141
}
4242
```
4343

44-
### 分发(Dispatch) Actions
44+
### 分发(Dispatch) Action
4545

4646
使用 `store.dispatch` 方法触发 action。
4747

src/vuex/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const store = new Vuex.Store({ ...options })
166166

167167
- **`mapState(map: Array<string> | Object): Object`**
168168

169-
创建一个组件的计算属性选项,该选项会返回 Vuex store 的子树 Create component computed options that return the sub tree of the Vuex store. [详细介绍](state.md#the-mapstate-helper)
169+
创建一个组件的计算属性选项,该选项会返回 Vuex store 的子树 [详细介绍](state.md#the-mapstate-helper)
170170

171171
- **`mapGetters(map: Array<string> | Object): Object`**
172172

0 commit comments

Comments
 (0)