: key="index"
Ref="inputRef"
:
Maxlength="1"
@ keydown="ceshi ($event, index)"
V - model="item. Val"/& gt;
pwdList: [{val: ""}, {val:" "}, {val: ""}, {val:" "}, {val: ""}, {val:" "}],
Methods:
Ceshi (el, index) {
Window. The console. The log (el, index)
Let RGX=/^ [0-9] * $/g
If (RGX. Test (el. Key)) {
This. $nextTick (()=& gt; {
This. $refs. InputRef [index + 1] focus ()
})
} else {
//alert (" please enter the number!!!!!! ')
This. $nextTick (()=& gt; {
Window. The console. The log (enclosing $refs. InputRef [index])
})
}
}
CodePudding user response:
Logical problems, a total of 6, should add data first, then methods of the if judgment and then go downCodePudding user response:
@ keydown="ceshi ($event, index)"To:
@ keyup="ceshi ($event, index)"
The reason is very simple keydown is to press the keyboard, there is no input, and this time the result you will move the focus,