forked from vueuse/vueuse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.vue
52 lines (51 loc) · 1016 Bytes
/
demo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script setup lang="ts">
import { ref } from 'vue'
import { useToFixed } from '@vueuse/math'
import type { FixedTypes } from '@vueuse/math'
const num = ref(314.15926)
const digits = ref(2)
const options = ref({
type: 'number',
math: 'round',
} as FixedTypes)
const value = useToFixed(num, digits, options)
</script>
<template>
<br>
input:
<input v-model="num" type="number">
digits:
<div>
<button @click="digits--">
-
</button>
{{ digits }}
<button @click="digits++">
+
</button>
</div>
type:
<div>
<button @click="options.type = 'string'">
string
</button>
<button @click="options.type = 'number'">
number
</button>
</div>
math:
<div>
<button @click="options.math = 'round'">
round
</button>
<button @click="options.math = 'floor'">
floor
</button>
<button @click="options.math = 'ceil'">
ceil
</button>
</div>
value:{{ value }}
<br>
typeof value:{{ typeof value }}
</template>