Skip to content

Update ja docs #986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions docs/ja/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Vuex

<!--email_off-->
> 注意: これは vuex@2.x のドキュメントです
<!--/email_off-->
> 注意: TypeScript ユーザ向けは、vuex@>= 3.0 と vue@>=2.5 が必須、逆もまた同様です。

- [1.0のドキュメントをお探しですか?](https://github.com/vuejs/vuex/tree/1.0/docs/ja)
- [リリースノート](https://github.com/vuejs/vuex/releases)
- [インストール](installation.md)
- [Vuex とは何か?](intro.md)
- [Vuex 入門](getting-started.md)
- コアコンセプト
- [コアコンセプト](core-concepts.md)
- [ステート](state.md)
- [ゲッター](getters.md)
- [ミューテーション](mutations.md)
Expand Down
29 changes: 25 additions & 4 deletions docs/ja/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const store = new Vuex.Store({ ...options })

- **state**

- 型: `Object`
- 型: `Object | Function`

ストアのための ルートステートオブジェクトです。
ストアのための ルートステートオブジェクトです。[詳細](state.md)

[詳細](state.md)
オブジェクトを返す関数を渡す場合、返されたオブジェクトはルートステートとして使用されます。これは特にモジュールの再利用のためにステートオブジェクトを再利用する場合に便利です。[詳細](modules.md#モジュールの再利用)

- **mutations**

Expand Down Expand Up @@ -156,10 +156,27 @@ const store = new Vuex.Store({ ...options })

プラグインの中でもっともよく利用されます。[詳細](plugins.md)

- **`registerModule(path: string | Array<string>, module: Module)`**
- **`subscribeAction(handler: Function)`**

> 2.5.0 で新規追加

ストアアクションを購読します。`handler` はディスパッチされたアクションごとに呼び出され、アクション記述子と現在のストア状態を引数として受け取ります:

``` js
store.subscribeAction((action, state) => {
console.log(action.type)
console.log(action.payload)
})
```

 プラグインで最も一般的に使用されます。[Details](plugins.md)

- **`registerModule(path: string | Array<string>, module: Module, options?: Object)`**

動的なモジュールを登録します。[詳細](modules.md#dynamic-module-registration)

`options` は前の状態を保存する `preserveState: true` を持つことができます。サーバサイドレンダリングに役立ちます。

- **`unregisterModule(path: string | Array<string>)`**

動的なモジュールを解除します。[詳細](modules.md#dynamic-module-registration)
Expand Down Expand Up @@ -193,3 +210,7 @@ const store = new Vuex.Store({ ...options })
ミューテーションをコミットするコンポーネントの methods オプションを作成します。[詳細](mutations.md#commiting-mutations-in-components)

第1引数は、オプションで名前空間文字列にすることができます。[詳細](modules.md#binding-helpers-with-namespace)

- **`createNamespacedHelpers(namespace: string): Object`**

名前空間付けられたコンポーネントバインディングのヘルパーを作成します。返されるオブジェクトは指定された名前空間にバインドされた `mapState`、`mapGetters`、`mapActions` そして `mapMutations` が含まれます。[詳細はこちら](modules.md#binding-helpers-with-namespace)
12 changes: 12 additions & 0 deletions docs/ja/core-concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# コアコンセプト

この章では、Vuex のコアコンセプトについて、以下を学習します。
- [ステート](state.md)
- [ゲッター](getters.md)
- [ミューテーション](mutations.md)
- [アクション](actions.md)
- [モジュール](modules.md)

これらのコンセプトを深く理解することは、Vuex を使用するにあたって不可欠です。

それでは、始めましょう!
27 changes: 27 additions & 0 deletions docs/ja/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ methods: {
}
```

さらに、`createNamespacedHelpers` を使用することによって名前空間付けされたヘルパーを作成できます。指定された名前空間の値にバインドされた新しいコンポーネントバインディングヘルパーを持つオブジェクトを返します:

``` js
import { createNamespacedHelpers } from 'vuex'

const { mapState, mapActions } = createNamespacedHelpers('some/nested/module')

export default {
computed: {
// `some/nested/module` を調べます
...mapState({
a: state => state.a,
b: state => state.b
})
},
methods: {
// `some/nested/module` を調べます
...mapActions([
'foo',
'bar'
])
}
}
```

#### プラグイン開発者向けの注意事項

モジュールを提供する[プラグイン](plugins.md)を作成し、ユーザーがそれらを Vuex ストアに追加できるようにすると、モジュールの予測できない名前空間が気になるかもしれません。あなたのモジュールは、プラグインユーザーが名前空間付きモジュールの元にモジュールを追加すると、その名前空間に属するようになります。この状況に適応するには、プラグインオプションを使用して名前空間の値を受け取る必要があります。
Expand Down Expand Up @@ -244,6 +269,8 @@ store.registerModule(['nested', 'myModule'], {

`store.unregisterModule(moduleName)` を呼び出せば、動的に登録したモジュールを削除できます。ただしストア作成(store creation)の際に宣言された、静的なモジュールはこのメソッドで削除できないことに注意してください。

サーバサイドレンダリングされたアプリケーションから状態を保持するなど、新しいモジュールを登録するときに、以前の状態を保持したい場合があります。`preserveState` オプション(`store.registerModule('a', module, { preserveState: true })`)でこれを実現できます。

### モジュールの再利用

時どき、モジュールの複数インスタンスを作成する必要があるかもしれません。例えば:
Expand Down
3 changes: 2 additions & 1 deletion docs/ja/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ const logger = createLogger({
// ミューテーションは、`{ type, payload }` の形式でログ出力されます
// 任意の方法でそれをフォーマットできます
return mutation.type
}
},
logger: console, // `console` API の実装, デフォルトは `console`
})
```

Expand Down
2 changes: 1 addition & 1 deletion docs/ja/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Counter = {

### `mapState`  ヘルパー

コンポーネントが複数のストアのステートプロパティやゲッターを必要としているとき、これらすべてにおいて、算出プロパティを宣言することは繰り返しで冗長です。これに対処するため、算出ゲッター関数を生成し、いくつかのキーストロークを節約するのに役立つ `mapState` ヘルパーを使うことができます:
コンポーネントが複数のストアのステートプロパティやゲッターを必要としているとき、これらすべてにおいて、算出プロパティを宣言することは繰り返しで冗長です。これに対処するため、算出ゲッター関数を生成し、いくつかのキーストロークを省くのに役立つ `mapState` ヘルパーを使うことができます:

```js
// 完全ビルドでは、ヘルパーは Vuex.mapState として公開されています
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ mocha test-bundle.js

#### Karma + karma-webpack を使ったブラウザでの実行

[vue-loader documentation](http://vue-loader.vuejs.org/en/workflow/testing.html) 内のセットアップ方法を参考にしてください。
[vue-loader ドキュメント](https://vue-loader.vuejs.org/ja/workflow/testing.html) 内のセットアップ方法を参考にしてください。