Skip to content

toValue

获取 value/ref/getter 的值。

¥Get the value of value/ref/getter.

警告

已弃用,改用 import { toValue } from 'vue'

¥Deprecated, use import { toValue } from 'vue' instead.

用法

¥Usage

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 on 1/2/2025
59f75 - feat: deprecate toValue from @vueuse/shared in favor of Vue's native

VueUse 中文网 - 粤ICP备13048890号