Skip to content

Commit deef14a

Browse files
committed
docs: swap more examples to destructuring for accessing the global Vue
vuejs/docs@e5b34b2#diff-e1a9e26e68d5a2cb4623864fbd565e0f3b01a6e17de1d884678f5130c64d52cd
1 parent 95add60 commit deef14a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/guide/state-management.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
Vue アプリケーションの情報源となっているのがリアクティブな `data` オブジェクト、すなわち、`data` オブジェクトへのアクセスのみをプロキシするコンポーネントインスタンスであることは見過ごされがちです。それゆえに、複数のインスタンスで共有されるべき状態がある場合、オブジェクトをリアクティブにするために [reactive](/guide/reactivity-fundamentals.html#declaring-reactive-state) 関数を利用できます:
1414

1515
```js
16-
const sourceOfTruth = Vue.reactive({
16+
const { createApp, reactive } = Vue
17+
18+
const sourceOfTruth = reactive({
1719
message: 'Hello'
1820
})
1921

20-
const appA = Vue.createApp({
22+
const appA = createApp({
2123
data() {
2224
return sourceOfTruth
2325
}
2426
}).mount('#app-a')
2527

26-
const appB = Vue.createApp({
28+
const appB = createApp({
2729
data() {
2830
return sourceOfTruth
2931
}
@@ -39,7 +41,7 @@ const appB = Vue.createApp({
3941
このようにすることで `sourceOfTruth` が変化するたびに、`appA``appB` の両方がそれぞれの view を自動的に更新します。いま、唯一の情報源を持っていることにはなりますが、デバッグは悪夢になるでしょう。あらゆるデータが、アプリケーションのどこからでも、そしていつでも、トレースを残すことなく変更できてしまうのです。
4042

4143
```js
42-
const appB = Vue.createApp({
44+
const appB = createApp({
4345
data() {
4446
return sourceOfTruth
4547
},
@@ -55,7 +57,7 @@ const appB = Vue.createApp({
5557
const store = {
5658
debug: true,
5759

58-
state: Vue.reactive({
60+
state: reactive({
5961
message: 'Hello!'
6062
}),
6163

@@ -88,7 +90,7 @@ Store の状態を変化させる action がすべて store 自身の中にあ
8890
```
8991

9092
```js
91-
const appA = Vue.createApp({
93+
const appA = createApp({
9294
data() {
9395
return {
9496
privateState: {},
@@ -100,7 +102,7 @@ const appA = Vue.createApp({
100102
}
101103
}).mount('#app-a')
102104

103-
const appB = Vue.createApp({
105+
const appB = createApp({
104106
data() {
105107
return {
106108
privateState: {},

0 commit comments

Comments
 (0)