NumberInput数字输入框
用于输入数字
尺寸
通过
size来设置尺寸大小 可选值有xssmmdlgxl
vue
<template>
<div class="flex flex-col gap-y-4">
<NumberInput
v-for="size in sizes"
:key="size"
v-model="numberValue"
:size="size"
:min="0"
:max="10"
/>
</div>
</template>
<script setup lang="ts">
import { NumberInput, type NumberInputSize } from 'li-daisy'
import { ref } from 'vue'
const sizes = ref<NumberInputSize[]>(['xs', 'sm', 'md', 'lg', 'xl'])
const numberValue = ref<number>(10)
</script>禁用状态
vue
<template>
<div class="flex flex-col gap-4">
<NumberInput
v-for="color in colors"
:key="color"
v-model="numberValue"
class="w-64 mx-auto"
:color="color"
:disabled="true"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { NumberInput, type NumberInputColor } from 'li-daisy'
const colors = ref<NumberInputColor[]>([
'base',
'neutral',
'primary',
'secondary',
'accent',
'info',
'success',
'warning',
'error',
])
const numberValue = ref<number>(10)
</script>最值
通过
min和max来分别设置最小和最大值
color颜色
通过
color来设置颜色可选值
[base,neutral,primary,secondary,accent,info,success,warning,error]
vue
<template>
<div class="flex flex-col gap-4">
<NumberInput
v-for="color in colors"
:key="color"
v-model="numberValue"
class="w-64 mx-auto"
:color="color"
:min="0"
:max="20"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { NumberInput, type NumberInputColor } from 'li-daisy'
const colors = ref<NumberInputColor[]>([
'base',
'neutral',
'primary',
'secondary',
'accent',
'info',
'success',
'warning',
'error',
])
const numberValue = ref<number>(10)
</script>API
Attributes
| 属性值 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| size | 尺寸 | NumberInputSize | 'md' |
| placeholder | 占位符 | string | - |
| disabled | 是否禁用 | boolean | false |
| min | 最小值 | number | - |
| max | 最大值 | number | - |
| color | 颜色 | NumberInputColor | base |