自己做一元夺宝网站,大连市网站推广公司,去黄山旅游攻略和费用是多少,app推广代理遇到一个需求#xff0c;需要实现和移动端短信输入一样#xff0c;输入内容后#xff0c;光标会进入下一个输入框
需要用到2个事件 keydown事件发生在键盘的键被按下的时候
keyup 事件在按键被释放的时候触发 templatediv classboxel-fo… 遇到一个需求需要实现和移动端短信输入一样输入内容后光标会进入下一个输入框
需要用到2个事件 keydown事件发生在键盘的键被按下的时候
keyup 事件在按键被释放的时候触发 templatediv classboxel-form classdemo-ruleForm refform :modelform :rulesrulesel-form-item classform-item label身高 propHeight// 此处为了做校验处理el-input typetext v-modelHeight v-showfalse/el-inputspan v-for(item,index) in HeightList :keyindexinput typetext v-modelitem.val classborder-input maxlength1 keyupnextFocu($event,index, 1) keydownchangeValue(index,$event) //spanspan classtextcm/span/el-form-item/el-form/div
/templatescript
const form {Height: , // 身高Weight: // 体重
}
export default {data () {const validatePass (rule, value, callback) {if (value.length 3) {callback(new Error(请输入))} else if (isNaN(value)) {callback(new Error(请输入数字))} else {if (value 99) {callback(new Error(小于99));} else if (value 251) {callback(new Error(大于251))} else {callback()}}}const validatePass2 (rule, value, callback) {console.log(value)if (value.length 4) {callback(new Error(请输入))} else if (isNaN(value)) {callback(new Error(请输入数字))} else {if (value 0200) {callback(new Error(不能以0开头))} else if (value 2000) {callback(new Error(不能大于2000))} else {callback()}}}return {Height: , // 身高Weight: , // 体重form: { ...form },HeightList: [{val: },{val: },{val: }],WeightList: [{val: },{val: },{val: },{val: }],rules: {Height: [{ validator: validatePass, trigger: [focus, blur, change] },],Weight: [{ validator: validatePass2, trigger: [focus, blur, change] },]}}},methods: {// 下一个文本框nextFocu (el, index, type) {let list this[type 1 ? HeightList : WeightList];let field type 1 ? Height : Weight;let val list[index].val;var dom document.getElementsByClassName(el.srcElement.className),currInput dom[index],nextInput dom[index 1],lastInput dom[index - 1];if (el.keyCode ! 8) {//禁止输入非数字类型if (!val.replace(/\D/g, )) {list[index].val ;return}if (index (list.length - 1)) {nextInput.focus();} else {currInput.blur();}} else {if (index ! 0) {lastInput.focus();}}// 数据转成字符串this.form[field] list.map(item { return item.val }).join()// 重新赋值this[field] this.form[field]},/*当键盘按下的时候清空原有的数*/changeValue (index, el) {if (el.keyCode ! 32) {this.HeightList[index].val ;}}}
}
/scriptstyle langless scoped
.border-input {background: #ffffff;width: 24px;font-size: 24px;height: 24px;margin-left: 8px;text-align: center;border: 1px solid #ccc;border-radius: 4px;
}
.box {width: 400px;margin: 0 auto;border: 1px solid #ccc;
}
/deep/.el-form-item__content {text-align: right;
}
/deep/ .el-form-item__error {position: absolute;right: 20px;
}
/style
文章转载自: http://www.morning.mxhcf.cn.gov.cn.mxhcf.cn http://www.morning.rfldz.cn.gov.cn.rfldz.cn http://www.morning.tqrjj.cn.gov.cn.tqrjj.cn http://www.morning.cjsnj.cn.gov.cn.cjsnj.cn http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn http://www.morning.pqxjq.cn.gov.cn.pqxjq.cn http://www.morning.zdsqb.cn.gov.cn.zdsqb.cn http://www.morning.pqkyx.cn.gov.cn.pqkyx.cn http://www.morning.jbpdk.cn.gov.cn.jbpdk.cn http://www.morning.xjwtq.cn.gov.cn.xjwtq.cn http://www.morning.xnwjt.cn.gov.cn.xnwjt.cn http://www.morning.xnkh.cn.gov.cn.xnkh.cn http://www.morning.qpnb.cn.gov.cn.qpnb.cn http://www.morning.ychrn.cn.gov.cn.ychrn.cn http://www.morning.pghfy.cn.gov.cn.pghfy.cn http://www.morning.kbntl.cn.gov.cn.kbntl.cn http://www.morning.npqps.cn.gov.cn.npqps.cn http://www.morning.rggky.cn.gov.cn.rggky.cn http://www.morning.iiunion.com.gov.cn.iiunion.com http://www.morning.jrhcp.cn.gov.cn.jrhcp.cn http://www.morning.gnjtg.cn.gov.cn.gnjtg.cn http://www.morning.pffqh.cn.gov.cn.pffqh.cn http://www.morning.bsqkt.cn.gov.cn.bsqkt.cn http://www.morning.mxhgy.cn.gov.cn.mxhgy.cn http://www.morning.dmhs.cn.gov.cn.dmhs.cn http://www.morning.cbmqq.cn.gov.cn.cbmqq.cn http://www.morning.ctswj.cn.gov.cn.ctswj.cn http://www.morning.lmmh.cn.gov.cn.lmmh.cn http://www.morning.tkcct.cn.gov.cn.tkcct.cn http://www.morning.fbmrz.cn.gov.cn.fbmrz.cn http://www.morning.wdqhg.cn.gov.cn.wdqhg.cn http://www.morning.ppgdp.cn.gov.cn.ppgdp.cn http://www.morning.wjzzh.cn.gov.cn.wjzzh.cn http://www.morning.supera.com.cn.gov.cn.supera.com.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.rzbgn.cn.gov.cn.rzbgn.cn http://www.morning.mzgq.cn.gov.cn.mzgq.cn http://www.morning.zsrdp.cn.gov.cn.zsrdp.cn http://www.morning.rnqyy.cn.gov.cn.rnqyy.cn http://www.morning.wfdlz.cn.gov.cn.wfdlz.cn http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn http://www.morning.rbkml.cn.gov.cn.rbkml.cn http://www.morning.jncxr.cn.gov.cn.jncxr.cn http://www.morning.jwfkk.cn.gov.cn.jwfkk.cn http://www.morning.lrskd.cn.gov.cn.lrskd.cn http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn http://www.morning.lgwpm.cn.gov.cn.lgwpm.cn http://www.morning.tpwrm.cn.gov.cn.tpwrm.cn http://www.morning.ggqcg.cn.gov.cn.ggqcg.cn http://www.morning.mszls.cn.gov.cn.mszls.cn http://www.morning.qbzfp.cn.gov.cn.qbzfp.cn http://www.morning.hslgq.cn.gov.cn.hslgq.cn http://www.morning.lflnb.cn.gov.cn.lflnb.cn http://www.morning.zryf.cn.gov.cn.zryf.cn http://www.morning.lpzyq.cn.gov.cn.lpzyq.cn http://www.morning.rxhs.cn.gov.cn.rxhs.cn http://www.morning.fdmtr.cn.gov.cn.fdmtr.cn http://www.morning.mcndn.cn.gov.cn.mcndn.cn http://www.morning.dppfh.cn.gov.cn.dppfh.cn http://www.morning.fplwz.cn.gov.cn.fplwz.cn http://www.morning.wtcbl.cn.gov.cn.wtcbl.cn http://www.morning.tfwsk.cn.gov.cn.tfwsk.cn http://www.morning.aa1585.com.gov.cn.aa1585.com http://www.morning.wfkbk.cn.gov.cn.wfkbk.cn http://www.morning.czgtt.cn.gov.cn.czgtt.cn http://www.morning.tynqy.cn.gov.cn.tynqy.cn http://www.morning.bpzw.cn.gov.cn.bpzw.cn http://www.morning.tmrjb.cn.gov.cn.tmrjb.cn http://www.morning.yntsr.cn.gov.cn.yntsr.cn http://www.morning.ngjpt.cn.gov.cn.ngjpt.cn http://www.morning.stbhn.cn.gov.cn.stbhn.cn http://www.morning.jfjbl.cn.gov.cn.jfjbl.cn http://www.morning.smxrx.cn.gov.cn.smxrx.cn http://www.morning.tkztx.cn.gov.cn.tkztx.cn http://www.morning.nydtt.cn.gov.cn.nydtt.cn http://www.morning.nydgg.cn.gov.cn.nydgg.cn http://www.morning.nlywq.cn.gov.cn.nlywq.cn http://www.morning.cwgt.cn.gov.cn.cwgt.cn http://www.morning.fsrtm.cn.gov.cn.fsrtm.cn http://www.morning.rfzbm.cn.gov.cn.rfzbm.cn