An Interest In:
Web News this Week
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
October 29, 2022 09:14 pm GMT
Original Link: https://dev.to/hshoja/vuejs-beginners-part-2-methods-1g7g
VueJs Beginners part 2 - Methods
To add methods to a component instance we use the methods
option.
we can define them the way we defined data
and indeed methods
is a object of functions.
const app = Vue.createApp({ data() { return { count: 0 } }, methods: { increment() { this.count++ } },)}
Event and key Modifiers:
It is a very common need to call something like event.preventDefault() inside event handlers. it can be done in method itself but there are some modifiers to apply them easier.
examples:
@[email protected]@keyup.13<!-- the submit event will no longer reload the page --><form @submit.prevent="onSubmit"></form><!-- only call `submit` when the `key` is `Enter` --><input @keyup.enter="submit" />
do you want more check here
Run and edit them yourself here
Original Link: https://dev.to/hshoja/vuejs-beginners-part-2-methods-1g7g
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To