There are some frequently used operations like event.preventDefault() or event.stopPropagation() inside event handlers. Although we can do this easily inside methods, it would be better if the methods can be purely about data logic rather than having to deal with DOM event details.
Vue provides event modifiers for v-on by calling directive postfixes denoted by a dot.
When listening for keyboard events, we often need to check for common key codes. Remembering all the keyCodes is a hassle, so Vue provides aliases for the most commonly used keys:
• .delete (captures both “Delete” and “Backspace” keys)
If you want user input to be trimmed automatically, you can add the trim modifier to your v-model
If you want user input to be automatically typecast as a number, you can do as follow:
Generally, v-model syncs the input with the data after each input event, but you can add the lazy modifier to instead sync after change events: