<el-col :span="12"> <el-form-item label="贷款金额" prop="loanAmount"> <el-input-number v-model="props.loanAmount" :min="0" @change="checkIntegerNumber('loanAmount')" controls-position="right" /> </el-form-item> </el-col>
<script setup lang="ts" name="test"> const checkIntegerNumber= (prop: any) => { const value = props.value[prop];
//校验整数 if (!/^\d+$/.test(value)) { props.value.[prop] = ""; } }; const checkNumber= (prop: any) => { const value = props.value[prop];
//校验两位小数 if (!/^\d+(\.\d{1,2})?$/.test(value)) { props.value.[prop] = ""; } }; </script>
标签:和校验,const,props,ts,value,prop,vue3,校验,小数 From: https://www.cnblogs.com/jsliao/p/18026793