1// 传入最大最小位数, 小数位数2function generateFloatRegexp (min, max, decimal) {3 return new RegExp(`^\\d{${min},${max}}(\\.\\d{0,${decimal}})?$`)4}5 6// 只传入小数位7function generateFloatRegexp (decLength) {8 return new RegExp(`(\\d+)${decLength ? `(\\.\\d{${decLength}})\\d*` : ''}`)9}