This commit is contained in:
2025-10-10 13:41:42 +08:00
parent a2faab2646
commit f1f65961dd
33 changed files with 4424 additions and 119 deletions
+15
View File
@@ -57,6 +57,21 @@ export default {
typeof func === 'function' && func()
}, wait)
}
},
checkInputPrice(value,max = null) {
if(max === 0){
return '';
}
// value = value.replace(/^0*/g, ''); // 第一个数不能为0 ,若为0替换为空
value = value.replace(/[^\d.]/g, ""); // 是否是数字 和小数点,若是除数字 和小数点之外的则替换为空
value = value.replace(/^\./g, ""); // 确证第一个为数字而不是“.”
value = value.replace(/\.{2,}/g, "."); // 只能输入一个“.”
value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); // 保证”.“只出现一次,而不能出现两次以上
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); // 只能输入两个小数
if(max && value >= max){
value = max;
}
return value;
}
}