InputNumber 数字输入框
数字输入框
import { DuInputNumber } from 'dangoui'
示例
<template>
<PreviewBlock title="基本">
<DuInputNumber :min="0" :max="6" highlight-add @change="handleChange" />
</PreviewBlock>
<PreviewBlock title="紧凑(没有值的时候只显示增加)">
<DuInputNumber :min="0" :max="6" compact highlight-add @change="handleChange" />
</PreviewBlock>
<PreviewBlock title="可以手动输入数字">
<DuInputNumber input :max="100" @change="handleChange" />
</PreviewBlock>
<PreviewBlock title="允许小数点">
<DuInputNumber input v-model:value="value" :max="100" allow-decimal @change="handleChange" />
</PreviewBlock>
<PreviewBlock title="步长">
<DuInputNumber :step="2" :max="100" @change="handleChange" />
</PreviewBlock>
<PreviewBlock title="禁用">
<DuInputNumber input size="mini" disabled />
</PreviewBlock>
<PreviewBlock title="不同大小">
<DuInputNumber input size="mini" />
<DuInputNumber input size="small" />
<DuInputNumber input size="normal" />
<DuInputNumber input size="medium" />
<DuInputNumber input size="large" />
</PreviewBlock>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { DuInputNumber } from 'dangoui'
const value = ref(0)
watch(value, (val) => {
console.log(`[demo] value changed: ${val}, typeof value ${typeof val}`)
})
function handleChange(v: number) {
console.log(`[demo] ${v}`)
}
</script>
0
各种颜色
<template>
<PreviewBlock title="secondary">
<DuInputNumber :min="0" :max="6" highlight-add color="secondary" />
</PreviewBlock>
<PreviewBlock title="success">
<DuInputNumber :min="0" :max="6" highlight-add color="success" />
</PreviewBlock>
<PreviewBlock title="warning">
<DuInputNumber :min="0" :max="6" highlight-add color="warning" />
</PreviewBlock>
<PreviewBlock title="error">
<DuInputNumber :min="0" :max="6" highlight-add color="error" />
</PreviewBlock>
<PreviewBlock title="trade">
<DuInputNumber :min="0" :max="6" highlight-add color="trade" />
</PreviewBlock>
<PreviewBlock title="vip">
<DuInputNumber :min="0" :max="6" highlight-add color="vip" />
</PreviewBlock>
</template>
<script setup lang="ts">
import { DuInputNumber } from 'dangoui'
</script>
0
API
属性
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
color | string | "primary" | 色板颜色 |
value | number | 0 | 值(数字) |
max | number | Infinity | 允许的最大值 |
size | "normal" | "mini" | "small" | "medium" | "large" | "mini" | 大小 |
min | number | 0 | 允许的最小值 |
input | boolean | false | 是否允许用户直接输入 |
step | number | 1 | 步长 |
disabled | boolean | - | 禁用 |
highlight-add | boolean | - | 强调增加按钮 |
highlight-minus | boolean | - | 强调较少按钮 |
allow-decimal | boolean | - | 允许小数 |
compact | boolean | - | 紧凑(0 的时候仅显示增加按钮) |
事件
名称 | 类型 |
---|---|
update:value | (event: "update:value", val: number): void |
input | (event: "input", val: number): void |
change | (event: "change", val: number): void |