Ant Design vue a-input-Number 只输入整数
html::formatter="numberRep " :parser="numberRep "<a-row><a-col :span="24"><a-form-model-item label="项目预警时间:"><a-input-number v-model="bodyFrom.earlyWarningTime"
·
html:
:formatter="numberRep " :parser="numberRep "
<a-row>
<a-col :span="24">
<a-form-model-item label="项目预警时间:">
<a-input-number v-model="bodyFrom.earlyWarningTime"
:formatter="numberRep " :parser="numberRep " :min="0" class="b-margin" style="width: 92%" />分钟
</a-form-model-item>
</a-col>
</a-row>
/* 只能输入整数 */ numberRep = (value: string | number) => { if (typeof value === 'string') { return !isNaN(Number(value)) ? value.replace(/^(0+)|[^\d]/g, '') : '' } else if (typeof value === 'number') { return !isNaN(value) ? String(value).replace(/^(0+)|[^\d]/g, '') : '' } else { return '' } }
更多推荐
已为社区贡献19条内容
所有评论(0)