2020-07-28 10:03:53 +08:00
|
|
|
---
|
2021-06-03 22:09:30 +08:00
|
|
|
title: InputNumber 数字输入框
|
2020-07-29 17:33:14 +08:00
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
type: 0
|
|
|
|
group: null
|
2021-06-03 22:09:30 +08:00
|
|
|
menuName: InputNumber
|
2020-07-29 17:33:14 +08:00
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
order: 32
|
|
|
|
---
|
2020-07-29 17:33:14 +08:00
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
## 基本用法
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "form",
|
2021-08-09 18:05:01 +08:00
|
|
|
"api": "/api/mock2/form/saveForm",
|
2021-06-03 22:09:30 +08:00
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
2021-06-03 22:09:30 +08:00
|
|
|
"type": "input-number",
|
2020-07-28 10:03:53 +08:00
|
|
|
"name": "number",
|
|
|
|
"label": "数字"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-08-18 14:53:26 +08:00
|
|
|
## 前后缀、千分分隔
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "form",
|
|
|
|
"api": "/api/mock2/form/saveForm",
|
|
|
|
"body": [
|
|
|
|
{
|
|
|
|
"type": "input-number",
|
|
|
|
"name": "number",
|
|
|
|
"label": "数字",
|
|
|
|
"value": 111111,
|
|
|
|
"prefix": "$",
|
2021-08-18 15:00:04 +08:00
|
|
|
"suffix": "%",
|
2021-08-18 14:53:26 +08:00
|
|
|
"kilobitSeparator": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-19 09:59:39 +08:00
|
|
|
## 带单位数字
|
|
|
|
|
2021-10-28 18:14:44 +08:00
|
|
|
> 1.4.0 及以上版本
|
2021-10-19 16:53:12 +08:00
|
|
|
|
2021-10-19 09:59:39 +08:00
|
|
|
可以通过 `unitOptions` 设置数字的单位选项,和前面的前后缀不同,它的输出结果也将会是字符串,包含单位,默认取选项的第一个。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "form",
|
|
|
|
"api": "/api/mock2/form/saveForm",
|
|
|
|
"debug": true,
|
|
|
|
"body": [
|
|
|
|
{
|
|
|
|
"type": "input-number",
|
|
|
|
"name": "number",
|
|
|
|
"label": "数字",
|
|
|
|
"unitOptions": ["px", "%", "em"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-26 14:23:45 +08:00
|
|
|
## 原生数字组件
|
|
|
|
|
|
|
|
原生数字组件将直接使用浏览器的实现,最终展现效果和浏览器有关,而且只支持 `min`、`max`、`step` 这几个属性设置。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "form",
|
2021-08-09 18:05:01 +08:00
|
|
|
"api": "/api/mock2/form/saveForm",
|
2021-06-03 22:09:30 +08:00
|
|
|
"body": [
|
2021-03-26 14:23:45 +08:00
|
|
|
{
|
|
|
|
"type": "native-number",
|
|
|
|
"name": "number",
|
|
|
|
"label": "数字"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
## 属性表
|
|
|
|
|
|
|
|
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
|
|
|
|
2021-10-19 09:59:39 +08:00
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
| ---------------- | --------------------------------------- | ------ | -------------------- |
|
|
|
|
| min | [模板](../../../docs/concepts/template) | | 最小值 |
|
|
|
|
| max | [模板](../../../docs/concepts/template) | | 最大值 |
|
|
|
|
| step | `number` | | 步长 |
|
|
|
|
| precision | `number` | | 精度,即小数点后几位 |
|
|
|
|
| showSteps | `boolean` | | 是否显示上下点击按钮 |
|
|
|
|
| prefix | `string` | | 前缀 |
|
|
|
|
| suffix | `string` | | 后缀 |
|
|
|
|
| kilobitSeparator | `boolean` | | 千分分隔 |
|
2022-03-16 20:48:29 +08:00
|
|
|
|
|
|
|
## 事件表
|
|
|
|
|
|
|
|
| 事件名称 | 事件参数 | 说明 |
|
|
|
|
| ------ | -------------------- | ------------------ |
|
|
|
|
| change | `value: number` 值变化 | 输入值发生变化时触发 |
|
|
|
|
| blur | - | - |
|
|
|
|
| focus | - | - |
|
|
|
|
|
|
|
|
## 动作表
|
|
|
|
|
|
|
|
| 动作名称 | 动作配置 | 说明 |
|
|
|
|
| -------- | ----- | ---- |
|
|
|
|
| clear | - | 清空 |
|