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

属性

属性名类型默认值说明
colorstring"primary"色板颜色
valuenumber0值(数字)
maxnumberInfinity允许的最大值
size"normal" | "mini" | "small" | "medium" | "large""mini"大小
minnumber0允许的最小值
inputbooleanfalse是否允许用户直接输入
stepnumber1步长
disabledboolean - 禁用
highlight-addboolean - 强调增加按钮
highlight-minusboolean - 强调较少按钮
allow-decimalboolean - 允许小数
compactboolean - 紧凑(0 的时候仅显示增加按钮)

事件

名称类型
update:value(event: "update:value", val: number): void
input(event: "input", val: number): void
change(event: "change", val: number): void
本页包含