欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue:el-input輸入時(shí)限制輸入的類型操作

 更新時(shí)間:2020年08月05日 09:45:56   作者:webfullstack  
這篇文章主要介紹了vue:el-input輸入時(shí)限制輸入的類型操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

通過(guò)@keyup.native的時(shí)間動(dòng)態(tài)監(jiān)控輸入的類型

1.手機(jī)號(hào)碼,只能是數(shù)字,如果輸入了非數(shù)字直接清空

2.身份證號(hào)碼,除了Xx和數(shù)字其余的一律清空

3.基于1.2兩種情況下,還有一種是動(dòng)態(tài)創(chuàng)建的字段(也就是v-for出來(lái)的),解決方法:先使用split形成字段數(shù)組,使用for循環(huán)找到最后一個(gè)點(diǎn)的前面的字段,方便使用$set更新和渲染頁(yè)面

setDelMsicStr(field,type){
   let props
   let len
   let value
   let newphoestr
   let item = this
   if (field) {
    props = field.split('.')
    len = props.length
    for (let i = 0; i < len - 1; i++) {
     item = item[props[i]]
    }
    if(type=="phone"){
     newphoestr = (item[props[len - 1]]).replace(/([^0-9])+/g, '')
    }else if(type=='idCard'){
     newphoestr = (item[props[len - 1]]).replace(/([^0-9Xx])+/g, '')
    }
    this.$set(item, props[len - 1], newphoestr)
   }
  },

重點(diǎn):也是使用this.$set()時(shí)必須的點(diǎn)

    for (let i = 0; i < len - 1; i++) {
     item = item[props[i]]
    }

表格限制輸入的數(shù)字長(zhǎng)度,超過(guò)限定值,直接顯示9999

          <el-form-item prop="activStoreSellPrice">
           <el-input type="number" @keyup.native="setRange('form.prdctStoreList.'+scope.$index+'.activStoreSellPrice',99999,0)" v-model.number="scope.row.activStoreSellPrice" :disabled="disabled" min="0" max="99999999"></el-input>
          </el-form-item>

重點(diǎn):

表格的需要獲取到行的index(scope.$index)

@keyup.native="setRange('form.prdctStoreList.'+scope.$index+'.activStoreSellPrice',99999,0)"

補(bǔ)充知識(shí):elementUI + vue 輸入框只能輸入正整數(shù) 不能輸入字母 e 以及+ - 號(hào)

看代碼吧~

<el-input :inline="true" v-model="dialogForm.closeTime" onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" type="number"></el-input>

以上這篇vue:el-input輸入時(shí)限制輸入的類型操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論