<script setup lang="ts">
import { ref } from 'vue'
const value = ref(0)
</script>
<template>
<div class="flex justify-center p-4 w-full">
<SkNumberInput v-model="value" placeholder="请输入数字" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
v-model | number | - | 设置数字输入框的值 (双向绑定) |
<script setup lang="ts">
import { ref } from 'vue'
const value = ref(0)
</script>
<template>
<div class="flex justify-center p-4 w-full">
<SkNumberInput v-model="value" placeholder="请输入数字" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
placeholder | string | - | 设置数字输入框占位符文本 |
<script setup lang="ts">
import { ref } from 'vue'
const value = ref()
</script>
<template>
<div class="flex flex-col gap-3 p-4">
<SkNumberInput v-model="value" placeholder="请输入数字" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
min | number | - | 设置数字输入框最小值 |
max | number | - | 设置数字输入框最大值 |
<script setup lang="ts">
import { ref } from 'vue'
const value1 = ref(0)
const value2 = ref(100)
</script>
<template>
<div class="flex flex-col p-4 gap-3">
<SkNumberInput v-model="value1" :min="0" :max="10" placeholder="范围 0-10" />
<SkNumberInput v-model="value2" :min="10" :max="100" placeholder="范围 10-100" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
step | number | 1 | 设置数字输入框步长 |
<script setup lang="ts">
import { ref } from 'vue'
const value1 = ref(0)
const value2 = ref(0)
</script>
<template>
<div class="flex flex-col p-4 gap-3">
<SkNumberInput v-model="value1" :step="5" placeholder="步长 5" />
<SkNumberInput v-model="value2" :step="0.1" placeholder="步长 0.1" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
stepStrictly | boolean | false | 设置数字输入框是否严格步长(值必须是步长的倍数) |
<script setup lang="ts">
import { ref } from 'vue'
const normalValue = ref(7)
const strictValue = ref(10)
</script>
<template>
<div class="flex flex-col p-4 gap-3">
<SkNumberInput v-model="normalValue" :step="5" placeholder="普通步长模式" />
<SkNumberInput v-model="strictValue" :step="5" step-strictly placeholder="严格步长模式" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
size | {Size} | medium | 设置数字输入框的尺寸大小 |
Size | 描述 |
---|
small | 小型 |
medium | 中型 |
large | 大型 |
<script setup lang="ts">
import { ref } from 'vue'
const smallValue = ref(0)
const mediumValue = ref(0)
const largeValue = ref(0)
</script>
<template>
<div class="flex flex-col items-center p-4 gap-3">
<SkNumberInput v-model="smallValue" size="small" placeholder="小尺寸" />
<SkNumberInput v-model="mediumValue" size="medium" placeholder="中尺寸" />
<SkNumberInput v-model="largeValue" size="large" placeholder="大尺寸" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
disabled | boolean | false | 设置数字输入框是否为禁用状态 |
<script setup lang="ts">
import { ref } from 'vue'
const normalValue = ref(10)
const disabledValue = ref(20)
</script>
<template>
<div class="flex flex-col p-4 gap-3 w-full">
<SkNumberInput v-model="normalValue" placeholder="正常状态" />
<SkNumberInput v-model="disabledValue" disabled placeholder="禁用状态" />
</div>
</template>
Prop | 类型 | 默认值 | 描述 |
---|
readonly | boolean | false | 设置数字输入框是否为只读状态 |
<script setup lang="ts">
import { ref } from 'vue'
const normalValue = ref(10)
const readonlyValue = ref(20)
</script>
<template>
<div class="flex flex-col p-4 gap-3 w-full">
<SkNumberInput v-model="normalValue" placeholder="正常状态" />
<SkNumberInput v-model="readonlyValue" readonly placeholder="只读状态" />
</div>
</template>
该属性目前处于实验性阶段,需要更加完备的测试,欢迎试用并提供反馈
Prop | 类型 | 默认值 | 描述 |
---|
formatOptions | Intl.NumberFormatOptions | - | 设置数字输入框格式化选项 |
<script setup lang="ts">
import { ref } from 'vue'
const currencyValue = ref(1000)
</script>
<template>
<div class="flex flex-col p-4 gap-3 w-full">
<SkNumberInput
v-model="currencyValue"
:format-options="{ style: 'currency', currency: 'CNY' }"
placeholder="货币格式"
/>
</div>
</template>
事件名 | 参数 | 描述 |
---|
change | (value: number) | 当输入框数值改变时触发 |
focus | (event: Event) | 当输入框获得焦点时触发 |
blur | (event: Event) | 当输入框失去焦点时触发 |
正在完善中,敬请期待!😊