Skip to content

Instantly share code, notes, and snippets.

@skvggor
Created September 26, 2017 02:57
Show Gist options
  • Save skvggor/a3e4d1f3c1721f00bd70cc27c256fc72 to your computer and use it in GitHub Desktop.
Save skvggor/a3e4d1f3c1721f00bd70cc27c256fc72 to your computer and use it in GitHub Desktop.
Organizing events
const Vue = require('../../node_modules/vue/dist/vue.common.js');
const App = new Vue({
delimiters: ['${', '}'],
el: '#app',
data: {
message: 'Default message',
greetings: {
hi: function() {
return 'hi';
},
hello: function() {
return 'hello';
}
}
},
methods: {
say: function(option) {
this.message = this.greetings[option]();
}
}
});
<main id="app" class="home">
<a @click.prevent="say('hi')" href="#">Click me - Hi!</a>
<br>
<a @click.prevent="say('hello')" href="#">Click me - Hello!</a>
<h1>${ message }</h1>
</main>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment