You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimeswemayneedtospecifycomplextypesforaref's inner value. We can do that succinctly by passing a generics argument when calling `ref` to override the default inference:
const unwrapped =unref(x) // unwrapped is guaranteed to be number now
54
+
const unwrapped = unref(x) // unwrapped は number であることが保証されます
55
55
}
56
56
```
57
57
58
58
## `toRef`
59
59
60
-
Can be used to create a [`ref`](#ref)for a property on a source reactive object. The ref can then be passed around, retaining the reactive connection to its source property.
`toRef`is useful when you want to pass the ref of a prop to a composition function:
77
+
`toRef`は、prop の refを composition関数に渡したいときに便利です:
78
78
79
79
```js
80
80
export default {
@@ -84,11 +84,11 @@ export default {
84
84
}
85
85
```
86
86
87
-
`toRef`will return a usable ref even if the source property doesn't currently exist. This makes it especially useful when working with optional props, which wouldn't be picked up by [`toRefs`](#torefs).
Converts a reactive object to a plain object where each property of the resulting object is a [`ref`](#ref)pointing to the corresponding property of the original object.
`toRefs`is useful when returning a reactive object from a composition function so that the consuming component can destructure/spread the returned object without losing reactivity:
`toRefs`will only generate refs for properties that are included in the source object. To create a ref for a specific property use [`toRef`](#toref)instead.
Creates a customized ref with explicit control over its dependency tracking and updates triggering. It expects a factory function, which receives `track`and`trigger`functions as arguments and should return an object with `get`and`set`.
0 commit comments