topic description
projects use vue 2.x, element-ui
customers have a need: customers are used to using the enter key to switch the focus of the control on the page, and the customer wants to press the enter key on the keyboard to achieve the next component to get the focus and continue to operate (the user does not want to press the Tab key).
question:
how to achieve the following effect in vue: when a user presses the enter key on the keyboard, it is equivalent to the effect that he presses the Tab key on the keyboard.
sources of topics and their own ideas
the current solution is:
- add an array object to each page to maintain all the components on the page.
- set a ref= "XXX" reference above each text box and select box on the page.
- add the @ keyup.enter.native= "selectXXX" event above each text box and select box on the page to get the ref and focus of the next component.
do you have any better solutions? It is best to replace carriage return events globally without having to write these event control codes separately on each page.