fn
useRound
v0.0.15testeddemoReactive `Math.round` with optional decimal-place precision
Examples
ts
const value = ref(0.6);
const rounded = useRound(value); // 1ts
const value = ref(1.2345);
const rounded = useRound(value, { digits: 2 }); // 1.23ts
const value = ref(0.5);
const rounded = useRound(() => value.value); // 1Demo
Loading demo…
Signature
ts
export function useRound(value: MaybeRefOrGetter<number>, options: UseRoundOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
value | MaybeRefOrGetter<number> | The value to round |
options? | UseRoundOptions | Rounding options |
Returns
ComputedRef<number>A computed ref of the rounded value