功能需求:做一个身份证后四位输入或汽车牌照输入,每个数字/字母一个input,想输入完当前的input后自动跳到下一个input,删除当前input后自动跳到前一个。
1、template代码
<div v-for="(item, index) in inputList" :key="index">
<input
type="text"
v-model="item.val"
class="inputValue"
@keyup="inputNextFocus($event, index)"
@keydown="cancelValue(index)"
/>
</div>
//注意:inputValue
2、script代码
data() {
return {
inputList: [{ val: "" }, { val: "" }, { val: "" }, { val: "" }], //根据个数
}
}
methods: {
inputNextFocus(el, index) {
var dom = document.getElementsByClassName("inputValue"), //引入inputValue
currInput = dom[index],
nextInput = dom[index + 1],
lastInput = dom[index - 1];
if (el.keyCode != 8) {
if (index < this.inputList.length - 1) {
nextInput.focus();
} else {
currInput.blur();
}
} else {
if (index != 0) {
lastInput.focus();
}
}
},
cancelValue(index) {
this.inputList[index].val = "";
}
}
上面是“vuejs实现输入完input自动跳到下一个input”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2177.html
workflows工作流
《翅膀之王:鸡的团契》海报ComfyUI工作流
一颗巨型的木星ComfyUI工作流
一只躲在一堆秋叶里的小刺猬
在地铁站里一个迷茫的非主流姑娘
树上挂着一只快乐香蕉ComfyUI工作流一
一只迷人的黑豹ComfyUI工作流
一只放屁虫甲虫ComfyUI工作流
一个人一条船一条鱼ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用css绘画棋盘布局(象棋)
如何利用css3+js做一个下雨效果
3d文字动画效果
用ascii字符画图像
3D立体人物效果
纯CSS饼图效果
HTML5 Canvas 刻度尺
3D彩色卡片







