Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Learn about the Vue directive v-on, and how to use how to use it in conjunction with Vue methods to respond to user events, such as button clicks.
v-on
A Vue directive used for event handling. Accepts events as arguments, such as:
- click
- dblclick
- keypress
- keydown
- keyup
- mouseover
- submit
v-on Syntax Example
<div id="app">
<h1 v-on:mouseover="functionToRun">Click Me!</h1>
</div>
new Vue({
el: '#app',
data: {
...
},
methods: {
functionToRun: function() {
//Do stuff on mouseover
}
}
});
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up