2016-03-31 14:17:09 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
subtitle: 数字输入框
|
2018-11-04 16:20:35 +08:00
|
|
|
type: 数据录入
|
2016-09-21 11:28:38 +08:00
|
|
|
title: InputNumber
|
2020-06-05 13:50:09 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/XOS8qZ0kU/InputNumber.svg
|
2016-03-31 14:17:09 +08:00
|
|
|
---
|
2015-07-01 14:48:47 +08:00
|
|
|
|
|
|
|
通过鼠标或键盘,输入范围内的数值。
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
2015-07-20 19:25:34 +08:00
|
|
|
当需要获取标准数值时。
|
2015-07-01 14:48:47 +08:00
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
属性如下
|
|
|
|
|
2020-10-10 17:49:50 +08:00
|
|
|
| 成员 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
| autoFocus | 自动获取焦点 | boolean | false | - |
|
|
|
|
| defaultValue | 初始值 | number | - | - |
|
|
|
|
| disabled | 禁用 | boolean | false | - |
|
|
|
|
| readOnly | 只读 | boolean | false | - |
|
|
|
|
| formatter | 指定输入框展示值的格式 | function(value: number \| string): string | - | - |
|
|
|
|
| max | 最大值 | number | [Number.MAX_SAFE_INTEGER](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) | - |
|
|
|
|
| min | 最小值 | number | [Number.MIN_SAFE_INTEGER](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER) | - |
|
|
|
|
| parser | 指定从 `formatter` 里转换回数字的方式,和 `formatter` 搭配使用 | function(string): number | - | - |
|
|
|
|
| precision | 数值精度 | number | - | - |
|
|
|
|
| decimalSeparator | 小数点 | string | - | - |
|
|
|
|
| size | 输入框大小 | `large` \| `middle` \| `small` | - | - |
|
|
|
|
| step | 每次改变步数,可以为小数 | number \| string | 1 | - |
|
|
|
|
| value | 当前值 | number | - | - |
|
|
|
|
| onChange | 变化回调 | function(value: number \| string) | - | - |
|
|
|
|
| onPressEnter | 按下回车的回调 | function(e) | - | - |
|
|
|
|
| onStep | 点击上下箭头的回调 | `(value: number, info: { offset: number, type: 'up' | 'down' }) => void` | - | 4.7.0 |
|
2017-12-01 19:28:41 +08:00
|
|
|
|
|
|
|
## 方法
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
| 名称 | 描述 |
|
|
|
|
| ------- | -------- |
|
|
|
|
| blur() | 移除焦点 |
|
|
|
|
| focus() | 获取焦点 |
|