From the course: Vue.js 3 Essential Training

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Event handling

Event handling

- [Instructor] I know you've been waiting for this. Let's take a look at how events work in Vue.js. The way you check for events being triggered is with the v-on directive. Now, this lets you listen to the DOM and run some JavaScripts when events are triggered and it looks like this. You use the v-on keyword, use the v-on directive, and then you type in the name of an event like the click event and then in here you can put in some JavaScript or call in a method if you want to. Now, there is a shortcut by using the at sign, you can get rid of the v-on colon. And this is the way that you'll see this used most often. So you can say at click and then execute a method. Now, if you don't include anything with the method it's going to automatically send event information which you can capture by receiving a variable and then using that variable to do something in your application. You can also pass along arguments. So if you…

Contents