Skip to content

Commit

Permalink
feat(input): modelValue 支持 number 类型 (#2635) (#2638)
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-boide authored Nov 9, 2023
1 parent c1eb2c1 commit a239dc4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/packages/__VUE/input/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const val = ref('');

| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| v-model | Input value, two-way binding | string | - |
| v-model | Input value, two-way binding | string \| number | - |
| type | Input type, support all native types and `number` `digit` type | string | `text` |
| placeholder | Placeholder when the input box is empty | string | - |
| input-align | Input align, eg `left``center``right` | string | `left` |
Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/input/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const val = ref('');

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| v-model | 输入值,双向绑定 | string | - |
| v-model | 输入值,双向绑定 | string \| number | - |
| type | 输入框类型,支持原生 `input` 标签的所有 `type` 属性,另外还支持 `number` `digit` | string | `text` |
| placeholder | 输入框为空时占位符 | string | - |
| input-align | 输入框内容对齐方式,可选值 `left``center``right` | string | `left` |
Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/input/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const val = ref('');

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| v-model | 输入值,双向绑定 | string | - |
| v-model | 输入值,双向绑定 | string \| number | - |
| type | 输入框类型,支持原生 `input` 标签的所有 `type` 属性,另外还支持 `number` `digit` | string | `text` |
| placeholder | 输入框为空时占位符 | string | - |
| input-align | 输入框内容对齐方式,可选值 `left``center``right` | string | `left` |
Expand Down
9 changes: 5 additions & 4 deletions src/packages/__VUE/input/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
></component>
<view v-if="readonly" class="nut-input-disabled-mask" @click="onClickInput"></view>
<view v-if="showWordLimit && maxLength" class="nut-input-word-limit">
<span class="nut-input-word-num">{{ modelValue ? modelValue.length : 0 }}</span
<span class="nut-input-word-num">{{ getModelValue() ? getModelValue().length : 0 }}</span
>/{{ maxLength }}
</view>
</view>
<view
v-if="clearable && !readonly"
v-show="(active || showClearIcon) && modelValue.length > 0"
v-show="(active || showClearIcon) && getModelValue().length > 0"
class="nut-input-clear-box"
@click="clear"
>
Expand Down Expand Up @@ -74,7 +74,7 @@ export default create({
default: 'text'
},
modelValue: {
type: String,
type: [String, Number],
default: ''
},
placeholder: {
Expand Down Expand Up @@ -350,7 +350,8 @@ export default create({
onClick,
onClickInput,
onConfirm,
onKeyup
onKeyup,
getModelValue
};
}
});
Expand Down
9 changes: 5 additions & 4 deletions src/packages/__VUE/input/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
@keyup="onKeyup"
></component>
<view v-if="showWordLimit && maxLength" class="nut-input-word-limit">
<span class="nut-input-word-num">{{ modelValue ? modelValue.length : 0 }}</span
<span class="nut-input-word-num">{{ getModelValue() ? getModelValue().length : 0 }}</span
>/{{ maxLength }}
</view>
</view>
<view
v-if="clearable && !readonly"
v-show="(active || showClearIcon) && modelValue.length > 0"
v-show="(active || showClearIcon) && getModelValue().length > 0"
class="nut-input-clear-box"
@click="clear"
>
Expand Down Expand Up @@ -68,7 +68,7 @@ export default create({
default: 'text'
},
modelValue: {
type: String,
type: [String, Number],
default: ''
},
placeholder: {
Expand Down Expand Up @@ -317,7 +317,8 @@ export default create({
focus,
blur,
select,
onKeyup
onKeyup,
getModelValue
};
}
});
Expand Down

0 comments on commit a239dc4

Please sign in to comment.