Get the ref of the current element in the vue click event

requirements: there are multiple Input input boxes in the form, each of which is input1, input2, input3. After the input1 input is complete, press the Enter key to automatically jump to input2. Similarly, press Enter to jump to input3 after input2 has been typed. It is true that it can be done in ref, but is there a better way to do multiple methods, or multiple judgment logic?

html section:

<input ref="wxInput" type="number" @keyup.enter.native="nextInput" .../>
<input ref="aliInput" type="number" @keyup.enter.native="nextInput" .../>
<input ref="unionInput" type="number" @keyup.enter.native="nextInput" .../>

js section:

nextInput(e) {
  // e.target.nextSibling.focus() // currentTarget  <!-- -->
  // e.target.$ref //  ref vue""
}

because there is automatic calculation logic here, it is difficult to change the original code.

question:
is there a better solution? Or is there a way to get the ref, or ref string of the current element in the element event? I really don"t want to write case when,if else that looks stupid.

Sep.28,2021

has a tabIndex attribute that you can take a look at


should be nextElementSibling,nextSibling 's next brother is inevitable.


ref is an attribute of the virtual Dom, while the virtual dom is bound to the root element of the component, so you can't get it in JS writing.
you don't have to be so complicated. Just pass parameters to the event nextInput directly @ enter=nextInput ($event, 'ref2'), which not only keeps the original event parameter, but also adds the name of ref as a parameter, right?
if helpful, please describe


since you don't want to write if else why bind the same function, just bind different functions


Why add a .native modifier here?
I tried it on codesandbox and it was OK

https://codesandbox.io/embed/.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b3bc-34629.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b3bc-34629.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?