Commit a8e8bcec authored by Michael Jörg's avatar Michael Jörg

Event Handling

parent c7771f65
<!DOCTYPE html>
<html lang="de">
<title>Vue.js Guide</title>
<script src=""></script>
<h1>Event Handling</h1>
<h2>Listening to Events</h2>
<div id="example-1">
<button v-on:click="counter += 1">Add 1</button>
<p>The button above has been clicked {{ counter }} times.</p>
<h2>Method Event Handlers</h2>
<div id="example-2">
<!-- `greet` is the name of a method defined below -->
<button v-on:click="greet">Greet</button>
<h2>Methods in Inline Handlers</h2>
<div id="example-3">
<button v-on:click="say('hi')">Say hi</button>
<button v-on:click="say('what')">Say what</button>
var example1 = new Vue({
el: '#example-1',
data: {
counter: 0
var example2 = new Vue({
el: '#example-2',
data: {
name: 'Vue.js'
// define methods under the `methods` object
methods: {
greet: function (event) {
// `this` inside methods points to the Vue instance
alert('Hello ' + + '!')
// `event` is the native DOM event
if (event) {
new Vue({
el: '#example-3',
methods: {
say: function (message) {
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment