Vue.js · Function
toRef
toRef() turns a value, ref, or getter into a ref, or links a ref to a property on a reactive object. The linked ref and source property stay synchronized.
Last updated
- Since
- 3.3+ for the normalization signature; the page does not stat
Syntax
function toRef<T>(value: T): T extends () => infer R ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>
function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue?: T[K]): ToRef<T[K]>In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
ref()toRefs()toValue()unref()reactive()computed()