Przeglądaj źródła

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

zhouna 6 lat temu
rodzic
commit
153eef096b
1 zmienionych plików z 3 dodań i 1 usunięć
  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;
     }