소스 검색

数字输入框字数限制10个

luolei 5 년 전
부모
커밋
6cd2cb5677
3개의 변경된 파일3개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 2
      src/common/Input.vue
  2. 1 3
      src/common/MultiLineInput.vue
  3. 1 2
      src/common/OptionInp.vue

+ 1 - 2
src/common/Input.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="inp-wrap" :style="getStyle(detail,slide)">
     <input :type="item.controlType==6?'text':'number'" 
-          :maxlength="item.controlType==6?'':10"
           :class="{'change':borColor}" 
           v-model="val" 
           @input="changeVal" 
@@ -49,7 +48,7 @@
       changeVal(e){
         this.borColor = true;
         if(this.item.controlType==7){//数字键盘
-          this.val = e.target.value=e.target.value.replace(/^\.$/,'')
+          this.val = e.target.value=e.target.value.replace(/^\.$/,'').slice(0,9)
         }
         // document.activeElement.scrollIntoViewIfNeeded(true);
         this.borColor = false;

+ 1 - 3
src/common/MultiLineInput.vue

@@ -14,7 +14,6 @@
               @input="changeVal($event,idx,content.type)" 
               @blur="blur"
               @focus="focus"
-              :maxlength="content.type=='number'?10:''"
               @click="handleClick">
             <input v-show="content.iptLis.length==1" class="contentVal" 
               :type="content.type=='number'?'number':'text'" 
@@ -23,7 +22,6 @@
               @input="changeVal($event,idx,content.type)" 
               @blur="blur"
               @focus="focus"
-              :maxlength="content.type=='number'?10:''"
               @click="handleClick">
             <span v-if="idx == 0&&content.iptLis.length>1">/</span>
           </template>
@@ -78,7 +76,7 @@ export default {
       let tmpTxt = '',arr=this.tmpArr
       document.activeElement.scrollIntoViewIfNeeded(true);
       if(type == 'number'){
-        e.currentTarget.value = e.currentTarget.value.replace(/^\.$/,'')
+        e.currentTarget.value = e.currentTarget.value.replace(/^\.$/,'').slice(0,9)
       }
       arr[num]=e.currentTarget.value
       tmpTxt=arr.join('/')

+ 1 - 2
src/common/OptionInp.vue

@@ -8,7 +8,6 @@
               :placeholder="msg.placeholder"
               :style="{'width':!msg.prefix&&!msg.suffix?'90%':'33%'}"
               :disabled="exclu"
-              :maxlength="msg.type=='number'?10:''"
               :class="[{'exclu':exclu},{'cancel':item.select==0}]"
               v-model="txt"
               @click="handleCli"
@@ -41,7 +40,7 @@ import $ from 'jquery';
     methods:{
       changeVal(e){
         if(this.msg.type=='number'){//数字键盘
-          this.txt = e.target.value=e.target.value.replace(/^\.$/,'')
+          this.txt = e.target.value=e.target.value.replace(/^\.$/,'').slice(0,9)
         }
         const newData = Object.assign({},this.part,{value:this.txt});
         this.$emit("updata",newData);