Skip to content

Commit c6ab969

Browse files
committed
doc: update api
1 parent 9cfeace commit c6ab969

File tree

2 files changed

+53
-19
lines changed

2 files changed

+53
-19
lines changed

components/input-number/index.en-US.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ When a numeric value needs to be provided.
1414
## API
1515

1616
| property | description | type | default |
17-
| --- | --- | --- | --- |
17+
| --- | --- | --- | --- | --- |
1818
| autofocus | get focus when component mounted | boolean | false |
1919
| defaultValue | initial value | number | |
2020
| disabled | disable the input | boolean | false |
@@ -27,17 +27,34 @@ When a numeric value needs to be provided.
2727
| size | height of input box | string | - |
2828
| step | The number to which the current value is increased or decreased. It can be an integer or decimal. | number\|string | 1 |
2929
| value(v-model) | current value | number | |
30+
| bordered | Whether has border style | boolean | true | 3.0 |
31+
| addonAfter | The label text displayed after (on the right side of) the input field | slot | - | 3.0 |
32+
| addonBefore | The label text displayed before (on the left side of) the input field | slot | - | 3.0 |
33+
| controls | Whether to show `+-` controls | boolean | true | 3.0 |
34+
| keyboard | If enable keyboard behavior | boolean | true | 3.0 |
35+
| stringMode | Set value as string to support high precision decimals. Will return string value by `change` | boolean | false | 3.0 |
3036

3137
### events
3238

3339
| Events Name | Description | Arguments | Version |
3440
| --- | --- | --- | --- | --- |
3541
| change | The callback triggered when the value is changed. | function(value: number \| string) | | |
3642
| pressEnter | The callback function that is triggered when Enter key is pressed. | function(e) | | 1.5.0 |
43+
| step | The callback function that is triggered when click up or down buttons | (value: number, info: { offset: number, type: 'up' \| 'down' }) => void | 3.0 |
3744

3845
## Methods
3946

4047
| Name | Description |
4148
| ------- | ------------ |
4249
| blur() | remove focus |
4350
| focus() | get focus |
51+
52+
## FAQ
53+
54+
### Why `value` can exceed `min` or `max` in control?
55+
56+
Developer handle data by their own in control. It will make data out of sync if InputNumber change display value. It also cause potential data issues when use in form.
57+
58+
### Why dynamic change `min` or `max` which makes `value` out of range will not trigger `change`?
59+
60+
`change` is user trigger event. Auto trigger will makes form lib can not detect data modify source.

components/input-number/index.zh-CN.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,48 @@ cover: https://gw.alipayobjects.com/zos/alicdn/XOS8qZ0kU/InputNumber.svg
1616

1717
属性如下
1818

19-
| 成员 | 说明 | 类型 | 默认值 |
20-
| --- | --- | --- | --- |
21-
| autofocus | 自动获取焦点 | boolean | false |
22-
| defaultValue | 初始值 | number | |
23-
| disabled | 禁用 | boolean | false |
24-
| formatter | 指定输入框展示值的格式 | function(value: number \| string): string | - |
25-
| max | 最大值 | number | Infinity |
26-
| min | 最小值 | number | -Infinity |
27-
| parser | 指定从 formatter 里转换回数字的方式,和 formatter 搭配使用 | function( string): number | - |
28-
| precision | 数值精度 | number | - |
29-
| decimalSeparator | 小数点 | string | - |
30-
| size | 输入框大小 | string ||
31-
| step | 每次改变步数,可以为小数 | number\|string | 1 |
32-
| value(v-model) | 当前值 | number | |
19+
| 成员 | 说明 | 类型 | 默认值 | 版本 |
20+
| --- | --- | --- | --- | --- |
21+
| autofocus | 自动获取焦点 | boolean | false | |
22+
| defaultValue | 初始值 | number | | |
23+
| disabled | 禁用 | boolean | false | |
24+
| formatter | 指定输入框展示值的格式 | function(value: number \| string): string | - | |
25+
| max | 最大值 | number | Infinity | |
26+
| min | 最小值 | number | -Infinity | |
27+
| parser | 指定从 formatter 里转换回数字的方式,和 formatter 搭配使用 | function( string): number | - | |
28+
| precision | 数值精度 | number | - | |
29+
| decimalSeparator | 小数点 | string | - | |
30+
| size | 输入框大小 | string || |
31+
| step | 每次改变步数,可以为小数 | number\|string | 1 | |
32+
| value(v-model) | 当前值 | number | | |
33+
| bordered | 是否有边框 | boolean | true | 3.0 |
34+
| addonAfter | 带标签的 input,设置后置标签 | slot | - | 3.0 |
35+
| addonBefore | 带标签的 input,设置前置标签 | slot | - | 3.0 |
36+
| controls | 是否显示增减按钮 | boolean | true | 3.0 |
37+
| keyboard | 是否启用键盘快捷行为 | boolean | true | 3.0 |
38+
| stringMode | 字符值模式,开启后支持高精度小数。同时 `change` 事件将返回 string 类型 | boolean | false | 3.0 |
3339

3440
### 事件
3541

36-
| 事件名称 | 说明 | 回调参数 | 版本 |
37-
| ---------- | -------------- | --------------------------------- | ---- |
38-
| change | 变化回调 | Function(value: number \| string) | |
39-
| pressEnter | 按下回车的回调 | function(e) | |
42+
| 事件名称 | 说明 | 回调参数 | 版本 |
43+
| --- | --- | --- | --- |
44+
| change | 变化回调 | Function(value: number \| string) | |
45+
| pressEnter | 按下回车的回调 | function(e) | |
46+
| step | 点击上下箭头的回调 | (value: number, info: { offset: number, type: 'up' \| 'down' }) => void | 3.0 |
4047

4148
## 方法
4249

4350
| 名称 | 描述 |
4451
| ------- | -------- |
4552
| blur() | 移除焦点 |
4653
| focus() | 获取焦点 |
54+
55+
## FAQ
56+
57+
### 为何受控模式下,`value` 可以超出 `min``max` 范围?
58+
59+
在受控模式下,开发者可能自行存储相关数据。如果组件将数据约束回范围内,会导致展示数据与实际存储数据不一致的情况。这使得一些如表单场景存在潜在的数据问题。
60+
61+
### 为何动态修改 `min``max``value` 超出范围不会触发 `change` 事件?
62+
63+
`change` 事件为用户触发事件,自行触发会导致表单库误以为变更来自用户操作。我们以错误样式展示超出范围的数值。

0 commit comments

Comments
 (0)