lanjianrong 4 年之前
父節點
當前提交
5e33050150
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/components/MoneyInput/index.tsx

+ 4 - 3
src/components/MoneyInput/index.tsx

@@ -38,7 +38,7 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
   useEffect(() => {
     if (value) {
       const len = value.match(/^(\d*)\.?(\d{0,2})/)
-      len && setDigit(digits[len[1].length])
+      len && setDigit(digits[parseFloat(len[1]).toString().length])
     }
   }, [ value ])
 
@@ -52,11 +52,12 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
   }
   const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
     const val = e.target.value?.match(/^(\d*)\.?(\d{0,2})/)
-    let newInputVal = val && val[0] || ''
+
+    const newInputVal = val && val[0] || ''
 
 
     if (newInputVal) {
-      newInputVal = parseFloat(newInputVal).toString()
+      // newInputVal = parseFloat(newInputVal).toString()
       // if (maxPrice && parseFloat(newInputVal) > maxPrice) {
       //   newInputVal = maxPrice.toString()
       // }