Skip to content

toRef

将 value/ref/getter 标准化为 refcomputed

¥Normalize value/ref/getter to ref or computed.

用法

¥Usage

ts
import { toRef } from '@vueuse/core'

const foo = ref('hi')

const a = toRef(0) // Ref<number>
const b = toRef(foo) // Ref<string>
const c = toRef(() => 'hi') // ComputedRef<string>