Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Libor Gess
6,880 PointsA bit confusing. The teacher working with folder call S1V3 but
Posted by Libor GessLibor Gess
6,880 Points1 Answer
-
Kristian Woods
23,414 Points2 Answers
-
Hai Huang
12,716 PointsCan I pass any arguments to the event handler function when using v-on directive?
Posted by Hai HuangHai Huang
12,716 Points1 Answer
View all discussions for this video
Related 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