Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: input的modelValue的类型支持number(#2635) #2638

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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