功能需求:做一个身份证后四位输入或汽车牌照输入,每个数字/字母一个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工作流
未来椅子3D产品ComfyUI工作流
半透明的玻璃苹果ComfyUI工作流
广阔的沙漠中矗立着一个生锈的巨大头盔
一只白色的孔雀ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

3d文字360度旋转
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
纯css3绘制的小鸟
css3+js菜单点击动态效果
做一个好玩的时钟翻牌效果
3d空间行走效果
javascript如何利用draggable实现一个拖拽效果
3D彩色卡片









