Answer the question
In order to leave comments, you need to log in
Why does vue call the click method on keypress event?
I don't understand why when you click on the input field of the Enter button, a click event occurs?
https://jsfiddle.net/h35y5jx7/2/
Answer the question
In order to leave comments, you need to log in
Because by default, the first button has type = submit, and pressing enter causes the form to submit and calls the handler on the button as well. For complete happiness, you need to specify type = "button" for the button, and specify the prevent modifier for keydown
https://jsfiddle.net/2kcLjsb3/
try to remove the type from the button, and you will see the output four in the console.
the same if you remove .prevent from keydown
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question