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
從 @vueuse/shared
以支持 Vue 原生寫法v12.0.0-beta.1
於 2024/11/21v10.0.0-beta.4
於 2023/4/134d757
- feat(types)!: 將 MaybeComputedRef
重新命名為 MaybeRefOrGetter
0a72b
- feat: 將 resolveUnref
重新命名為 toValue