File tree 1 file changed +17
-2
lines changed 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,14 @@ console.log(count.value) // 1
45
45
46
46
### ref のアンラップ
47
47
48
- ref がレンダーコンテキスト(render contenxt - [ setup()] ( composition-api-setup.html ) によって返されるオブジェクト)のプロパティとして返されていてテンプレート内でアクセスされる場合、自動的に内部の値にアンラップ (ref でラップされた値を取り出す)されます。テンプレート内においては ` .value ` を付ける必要はありません :
48
+ ref がレンダーコンテキスト(render contenxt - [ setup()] ( composition-api-setup.html ) によって返されるオブジェクト)のプロパティとして返されていてテンプレート内でアクセスされる場合、自動的に内部の値に浅くアンラップ (ref でラップされた値を取り出す)されます。ネストした ref だけが、テンプレート内で ` .value ` が必要です :
49
49
50
50
``` vue-html
51
51
<template>
52
52
<div>
53
53
<span>{{ count }}</span>
54
54
<button @click="count ++">Increment count</button>
55
+ <button @click="nested.count.value ++">Nested Increment count</button>
55
56
</div>
56
57
</template>
57
58
@@ -61,13 +62,27 @@ ref がレンダーコンテキスト(render contenxt - [setup()](composition-ap
61
62
setup() {
62
63
const count = ref(0)
63
64
return {
64
- count
65
+ count,
66
+
67
+ nested: {
68
+ count
69
+ }
65
70
}
66
71
}
67
72
}
68
73
</script>
69
74
```
70
75
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
+
71
86
### リアクティブオブジェクト内でのアクセス
72
87
73
88
` ref ` がリアクティブオブジェクトのプロパティとしてアクセスまたは更新される際に、自動的に内部の値にアンラップされて通常のプロパティのように振る舞います:
You can’t perform that action at this time.
0 commit comments