Browse Source

数字组件允许输入.等黏贴无法判断

zhouna 6 năm trước cách đây
mục cha
commit
153eef096b
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      src/components/NumberDrop/index.jsx

+ 3 - 1
src/components/NumberDrop/index.jsx

@@ -118,7 +118,9 @@ class NumberDrop extends Component{
     handleEnter();
     //只能输入数字
     const key = e.key;
-    if(!/[0-9]/.test(key)){
+    const ctrlOn = e.ctrlKey;
+    const isCopyPaste = ctrlOn&&(key=='v'||key=='c');
+    if(!/[0-9|.|~|\/]/.test(key)&&key.length==1&&!isCopyPaste){
       e.preventDefault();
       return false;
     }