跳到主要內容

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

原始碼

Source文件

貢獻者

Anthony Fu
Anthony Fu

更新日誌

v12.3.0 於 2025/1/2
59f75 - feat: 棄用 toValue@vueuse/shared 以支持 Vue 原生寫法
v12.0.0-beta.1 於 2024/11/21
0a9ed - feat!: 移除 Vue 2 支援,優化 bundle 並清理 (#4349)
v10.0.0-beta.4 於 2023/4/13
4d757 - feat(types)!: 將 MaybeComputedRef 重新命名為 MaybeRefOrGetter
0a72b - feat: 將 resolveUnref 重新命名為 toValue

以 MIT 授權條款發布。