Vue键盘事件用法(流量充值项目记录)
<label for="haha">键盘事件:</label> <input class="ipt" @keyup="keyFun" v-model="tel" name="haha"/>
keyFun(event){ if (event.keyCode!=8&&event.keyCode!=46) { var val=this.tel //console.log(val) if (val.length == 3) { this.tel=val + ' ' } if (val.length == 8) { this.tel=val + ' ' } if (val.length>13) { this.tel=val.substr(0,13) } } }