Skip to content

Commit f748809

Browse files
committed
1 parent bea9ba7 commit f748809

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/guide/reactivity-fundamentals.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ console.log(count.value) // 1
4545

4646
### ref のアンラップ
4747

48-
ref がレンダーコンテキスト(render contenxt - [setup()](composition-api-setup.html) によって返されるオブジェクト)のプロパティとして返されていてテンプレート内でアクセスされる場合、自動的に内部の値にアンラップ(ref でラップされた値を取り出す)されます。テンプレート内においては `.value` を付ける必要はありません:
48+
ref がレンダーコンテキスト(render contenxt - [setup()](composition-api-setup.html) によって返されるオブジェクト)のプロパティとして返されていてテンプレート内でアクセスされる場合、自動的に内部の値に浅くアンラップ(ref でラップされた値を取り出す)されます。ネストした ref だけが、テンプレート内で `.value` が必要です:
4949

5050
```vue-html
5151
<template>
5252
<div>
5353
<span>{{ count }}</span>
5454
<button @click="count ++">Increment count</button>
55+
<button @click="nested.count.value ++">Nested Increment count</button>
5556
</div>
5657
</template>
5758
@@ -61,13 +62,27 @@ ref がレンダーコンテキスト(render contenxt - [setup()](composition-ap
6162
setup() {
6263
const count = ref(0)
6364
return {
64-
count
65+
count,
66+
67+
nested: {
68+
count
69+
}
6570
}
6671
}
6772
}
6873
</script>
6974
```
7075

76+
::tip
77+
If you don't need to access the actual object instance, you can wrap it in a reactive:
78+
79+
```js
80+
rested: reactive({
81+
count
82+
})
83+
```
84+
::
85+
7186
### リアクティブオブジェクト内でのアクセス
7287

7388
`ref` がリアクティブオブジェクトのプロパティとしてアクセスまたは更新される際に、自動的に内部の値にアンラップされて通常のプロパティのように振る舞います:

0 commit comments

Comments
 (0)