To attach an event handler to an element, add v-on:event
or @event
attribute to the element. The attribute value can take either a JavaScript statement, or the name of a method to call when the event happens.
In addition, this example demonstrates how to define a method in the options object. It also uses JavaScript timers.
Click count: {{ count }}
Try the following
vm
. This object has one data property vm.count
and two methods. vm.reset()
and vm.countUp(n)
.alert('button clicked')