跳到内容

toValue

类别
导出大小
106 B
最后更改
3 个月前
别名
resolveUnref
相关

获取 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

源码

源码文档

贡献者

Anthony Fu
Anthony Fu

更新日志

v12.3.0 于 2025/1/2
59f75 - feat: 弃用 toValue from @vueuse/shared,转而使用 Vue 原生的
v12.0.0-beta.1 于 2024/11/21
0a9ed - feat!: 移除 Vue 2 支持,优化包大小并清理代码 (#4349)
v10.0.0-beta.4 于 2023/4/13
4d757 - feat(types)!: 重命名 MaybeComputedRefMaybeRefOrGetter
0a72b - feat: 重命名 resolveUnreftoValue

根据 MIT 许可证发布。