ant输入框的后缀是动态计算的,输入数字的范围限定在1-31,也就是日期,如果输入其他不在这个范围的数字就不会返回相应的后缀,在试验的过程中,发现以下4种情况会导致输入框失去焦点:
<a-input v-model.trim="formData[item].startDate" :suffix="getSuffix(formData[item].startDate)" class="w-240px" />
const getSuffix = (date) => {
const day = parseInt(date)
let suffix = ''
if (day && day > 0 && day <= 31) {
const str = moment(date, 'DD').format('Do')
suffix = str.substring(str.length - 2)
}
return suffix
}
1、从没有输入到输入一个个位数的数字,输入框会失去焦点,需要重新手动聚焦
2、从有输入且在范围内到输入不是范围内的数字会失去焦点
3、从有输入且不在范围内的数字到有输入且在范围内的会失去焦点
4、从有输入且在范围内到完全没有输入会失去焦点
请问我要怎么保持在输入数字的时候不会突然失去焦点
已解决
https://github.com/vueComponent/ant-design-vue/issues/685