Skip to content

Commit 7aa21b0

Browse files
fix: 🐛 修复Input支付宝小程序number/digit类型使用maxlength=-1时v-model失效的问题
1 parent 8e15dff commit 7aa21b0

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

docs/component/input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function handleChange(event) {
120120
| v-model | 绑定值 | string / number | - | - | - |
121121
| placeholder | 占位文本 | string | - | 请输入... | - |
122122
| clearable | 显示清空按钮 | boolean | - | false | - |
123-
| maxlength | 原生属性,最大长度 | string | - | - | - |
123+
| maxlength | 原生属性,最大长度 | number | - | 支付宝小程序无默认值,其余平台默认为-1 | - |
124124
| showPassword | 显示为密码框 | boolean | - | false | - |
125125
| disabled | 原生属性,禁用 | boolean | - | false | - |
126126
| readonly | 只读 | boolean | - | false | - |

src/pages/input/Index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<demo-block title="密码框">
1919
<wd-input type="text" v-model="value5" disabled clearable show-password @change="handleChange2" />
2020
</demo-block>
21+
<demo-block title="数字类型">
22+
<wd-input type="number" v-model="value9" />
23+
</demo-block>
2124
<demo-block title="设置前后Icon">
2225
<wd-input type="text" v-model="value6" prefix-icon="dong" suffix-icon="list" clearable @change="handleChange3" />
2326
</demo-block>
@@ -58,9 +61,7 @@ const value5 = ref<string>('password')
5861
const value6 = ref<string>('')
5962
const value7 = ref<string>('1234')
6063
const value8 = ref<string>('')
61-
const value9 = ref<string>('')
62-
const value10 = ref<string>('支持清空和字数限制的文本域')
63-
const value11 = ref<string>('输入文字后,输入框高度跟随字数多少变化')
64+
const value9 = ref<number | null>(null)
6465
const value12 = ref<string>('')
6566
const value13 = ref<string>('该输入框禁用')
6667
const value14 = ref<string>('12345678')

src/uni_modules/wot-design-uni/components/wd-input/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ export const inputProps = {
6161
/**
6262
* 原生属性,最大长度
6363
*/
64-
maxlength: makeNumberProp(-1),
64+
maxlength: {
65+
type: Number,
66+
// #ifndef MP-ALIPAY
67+
default: -1
68+
// #endif
69+
},
6570
/**
6671
* 原生属性,禁用
6772
*/

src/uni_modules/wot-design-uni/components/wd-input/wd-input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<text
5858
:class="[
5959
inputValue && String(inputValue).length > 0 ? 'wd-input__count-current' : '',
60-
String(inputValue).length > maxlength ? 'is-error' : ''
60+
String(inputValue).length > maxlength! ? 'is-error' : ''
6161
]"
6262
>
6363
{{ String(inputValue).length }}

0 commit comments

Comments
 (0)