Skip to content

Commit

Permalink
Merge pull request #146 from menpuji/2.0-cn
Browse files Browse the repository at this point in the history
热重载 翻译
  • Loading branch information
dingyiming authored Oct 10, 2016
2 parents e75e89e + 6fbee66 commit bd4fcc4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/vuex/hot-reload.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: 热加载
title: 热重载
type: vuex
order: 14
---

Vuex supports hot-reloading mutations, modules, actions and getters during development, using Webpack's [Hot Module Replacement API](https://webpack.github.io/docs/hot-module-replacement.html). You can also use it in Browserify with the [browserify-hmr](https://github.com/AgentME/browserify-hmr/) plugin.
Vuex 支持在开发中使用webpack的[Hot Module Replacement API](https://webpack.github.io/docs/hot-module-replacement.html) 热重载 mutations,modules ,actions 和 getters,你也可以在 Browserify 里使用 [browserify-hmr](https://github.com/AgentME/browserify-hmr/) 插件来实现同样的功能。

For mutations and modules, you need to use the `store.hotUpdate()` API method:
对于mutations 和 modules,你只需要简单地调用 store.hotUpdate():

``` js
// store.js
Expand All @@ -28,13 +28,13 @@ const store = new Vuex.Store({
})

if (module.hot) {
// accept actions and mutations as hot modules
// 使 actions mutations 成为可热重载模块
module.hot.accept(['./mutations', './modules/a'], () => {
// require the updated modules
// have to add .default here due to babel 6 module output
// 获取更新后的模块
// 因为 babel 6 的模块编译格式问题,这里需要加上 .default
const newMutations = require('./mutations').default
const newModuleA = require('./modules/a').default
// swap in the new actions and mutations
// 成新的 mutation 和 mudule
store.hotUpdate({
mutations: newMutations,
modules: {
Expand All @@ -45,4 +45,4 @@ if (module.hot) {
}
```

Checkout the [counter-hot example](https://github.com/vuejs/vuex/tree/dev/examples/counter-hot) to play with hot-reload.
查看[热重载的例子](https://github.com/vuejs/vuex/tree/dev/examples/counter-hot) 来开始使用热重载

0 comments on commit bd4fcc4

Please sign in to comment.