Skip to content

Commit fdb8ee0

Browse files
authored
Update ja docs (#642)
* Update getter docs #601 for ja * [docs] add a note that registerModule can receive an array of string #634 for ja
1 parent 290ee83 commit fdb8ee0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/ja/getters.md

+15
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ computed: {
6161
}
6262
```
6363

64+
関数を返り値にすることで、ゲッターに引数を渡すこともできます。これは特にストアの中の配列を検索する時に役立ちます:
65+
```js
66+
getters: {
67+
// ...
68+
getTodoById: (state, getters) => (id) => {
69+
return getters.todos.find(todo => todo.id === id)
70+
}
71+
}
72+
```
73+
74+
``` js
75+
store.getters.getTodoById(2) // -> { id: 2, text: '...', done: false }
76+
```
77+
78+
6479
### `mapGetters` ヘルパー
6580

6681
`mapGetters` ヘルパーはストアのゲッターをローカルの算出プロパティにマッピングさせます:

docs/ja/modules.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,18 @@ export function createPlugin (options = {}) {
227227
ストアが作られた****`store.registerModule` メソッドを使って、モジュールを登録できます:
228228

229229
``` js
230+
// `myModule` モジュールを登録します
230231
store.registerModule('myModule', {
231232
// ...
232233
})
234+
235+
// ネストされた `nested/myModule` モジュールを登録します
236+
store.registerModule(['nested', 'myModule'], {
237+
// ...
238+
})
233239
```
234240

235-
モジュールのステートには `store.state.myModule` でアクセスします。
241+
モジュールのステートには `store.state.myModule` `store.state.nested.myModule` でアクセスします。
236242

237243
動的なモジュール登録があることで、他の Vue プラグインが、モジュールをアプリケーションのストアに付属させることで、状態の管理に Vuex を活用できることができます。例えば [`vuex-router-sync`](https://github.com/vuejs/vuex-router-sync) ライブラリは、動的に付属させたモジュール内部でアプリケーションのルーティングのステートを管理することで vue-router と vuex を統合しています。
238244

0 commit comments

Comments
 (0)