博客
关于我
一个车牌输入组件(vue)
阅读量:386 次
发布时间:2019-03-05

本文共 4128 字,大约阅读时间需要 13 分钟。

一个简单的车牌输入组件(vue)

效果图:
在这里插入图片描述
vue代码:

event事件:

export let life = {     created () {       // this.currentPlate = this.plateNumber    // console.log(this.plateNumber)    // this.EnterPlateNumber.input.firstWord = this.plateNumber.slice(0,1)    // this.EnterPlateNumber.input.secondWord = this.plateNumber.slice(1,2)    // this.EnterPlateNumber.input.lastWords = this.plateNumber.slice(2,9)  }}export let event = {     clickInput (type) {       this.methods('clickInput',type)  },  clickKeyboard (val) {       if (this.plateInput.input.type === 'p2' && parseInt(val) >= 0 && parseInt(val) <= 9) return    this.methods('clickKeyboard', val)    this.methods('setPlateNumber')    this.methods('setDirectIssuedPlateNumber')  },  //删除车牌  clickDelete () {       this.methods('clickDelete')    this.methods('setPlateNumber')    this.methods('setDirectIssuedPlateNumber')  },  hiddenKeybord(){       this.methods('hiddenKeybord')  },  enterWord(){       this.methods('enterWord')  }}export let watch = {   }

methods方法:

export default class {     clickInput(type){       this.plateInput.input.type = type    this.plateInput.input.dialogVisible = true  }  hiddenKeybord(){       this.plateInput.input.dialogVisible = false  }  enterWord(){       this.plateInput.input.dialogVisible = false  }  clickKeyboard (val) {       this.plateInput.input.value[this.plateInput.input.type] = val    let type = this.plateInput.input.type.split('p')[1]    if (type !== '8') {         this.plateInput.input.type = 'p' + (parseInt(type) + 1)    }  }  clickDelete () {       this.plateInput.input.value[this.plateInput.input.type] = undefined    let nu = this.plateInput.input.type.split('p')[1]-1    if(nu>=0){         this.plateInput.input.value['p'+nu] = undefined    }    let type = this.plateInput.input.type.split('p')[1]    if (type !== '1') {         this.plateInput.input.type = 'p' + (parseInt(type) - 1)    }  }  setPlateNumber () {       if (this.plateInput.input.plateNumber) {         this.plateNumber1 = this.plateInput.input.plateNumber    }else{         this.plateNumber1 = undefined    }  }  setDirectIssuedPlateNumber () {       if (this.plateInput.input.plateNumber) {         this.plateNumber1 = this.plateInput.input.plateNumber    }else{         this.plateNumber1 = undefined    }  }}

model数据:

export let props = ['name','plateNumber','noRightPart']export let model = {     currentPlate:undefined,  plateInput:{       input:{         value:{           p1:'桂',        p2:'B',        p3:2,        p4:2,        p5:2,        p6:2,        p7:2,        p8:0      },      type:'p1',      dialogVisible:false    }  },  Keyboard: {       province: ['京', '津', '冀', '晋', '蒙', '辽', '吉', '黑', '沪', '苏', '浙', '皖', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '桂', '琼', '渝', '川', '贵', '云', '藏', '陕', '甘', '青','宁','新','台','港','澳','使','领','警','学'],    number: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C','D', 'E', 'F', 'G','H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '学', '港', '澳']  },}export let computed = {     plateNumber1 : {       get () {         return this.plateNumber||''    },    set (val) {         this.$emit('update:plateNumber', val)    }  }}

因为这里用了独家的框架,所以根据需要把相应的生命周期函数放到正常的vue项目的位置,把event就写成正常的函数,methods就是i正常的methods里面的方法,model就是data里return的数据

转载地址:http://ksgwz.baihongyu.com/

你可能感兴趣的文章
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Nginx、HAProxy、LVS
查看>>
nginx一些重要配置说明
查看>>
Nginx下配置codeigniter框架方法
查看>>
Nginx与Tengine安装和使用以及配置健康节点检测
查看>>
Nginx中使用expires指令实现配置浏览器缓存
查看>>
Nginx中实现流量控制(限制给定时间内HTTP请求的数量)示例
查看>>
nginx中配置root和alias的区别
查看>>
nginx主要流程(未完成)
查看>>
Nginx之二:nginx.conf简单配置(参数详解)
查看>>
Nginx从入门到精通
查看>>
Nginx代理websocket配置(解决websocket异常断开连接tcp连接不断问题)
查看>>
Nginx代理初探
查看>>
nginx代理地图服务--离线部署地图服务(地图数据篇.4)
查看>>
Nginx代理外网映射
查看>>