跳到主要內容

useTrunc

類別
匯出大小
144 B
套件
@vueuse/math
上次變更
5 天前

響應式的 Math.trunc

用法

ts
import { useTrunc } from '@vueuse/math'

const value1 = ref(0.95)
const value2 = ref(-2.34)
const result1 = useTrunc(value1) // 0
const result2 = useTrunc(value2) // -2

類型宣告

typescript
/**
 * Reactive `Math.trunc`.
 *
 * @see https://vueuse.dev.org.tw/useTrunc
 */
export declare function useTrunc(
  value: MaybeRefOrGetter<number>,
): ComputedRef<number>

原始碼

原始碼文件

貢獻者

Anthony Fu
Anthony Fu
IlyaL
hanpei

變更日誌

v12.8.0 於 2025/3/5
7432f - feat(types): 棄用 MaybeRefMaybeRefOrGetter,改用 Vue 原生型別 (#4636)
v12.3.0 於 2025/1/2
59f75 - feat(toValue): 棄用 @vueuse/shared 中的 toValue,改用 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(toValue): 將 resolveUnref 重新命名為 toValue

以 MIT 授權條款發布。