toValue
获取 value/ref/getter 的值。
警告
已弃用,请使用 import { toValue } from 'vue' 代替。
用法
ts
import { toValue } from '@vueuse/core'
const foo = ref('hi')
const a = toValue(0) // 0
const b = toValue(foo) // 'hi'
const c = toValue(() => 'hi') // 'hi'类型声明
typescript
/**
* Get the value of value/ref/getter.
*
* @deprecated use `toValue` from `vue` instead
*/
export declare const toValue: typeof _toValue
/**
* @deprecated use `toValue` instead
*/
export declare const resolveUnref: typeof _toValue源码
贡献者
更新日志
v12.3.0 于 2025/1/259f75 - feat: 弃用 toValue from @vueuse/shared,转而使用 Vue 原生的v12.0.0-beta.1 于 2024/11/21v10.0.0-beta.4 于 2023/4/134d757 - feat(types)!: 重命名 MaybeComputedRef 为 MaybeRefOrGetter0a72b - feat: 重命名 resolveUnref 为 toValue