Skip to content

Instantly share code, notes, and snippets.

@anlek
Created May 11, 2016 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anlek/bd20598692459a10e84b8e9b9467b0bd to your computer and use it in GitHub Desktop.
Save anlek/bd20598692459a10e84b8e9b9467b0bd to your computer and use it in GitHub Desktop.
<template lang="jade">
#example
button(@click="greet") Greet
</template>
<script>
export default {
data () {
return {
// note: changing this line won't causes changes
// with hot-reload because the reloaded component
// preserves its current state and we are modifying
// its initial state.
msg: 'Hello World!!?!'
}
},
methods: {
greet: (event) => {
// `this` inside methods point to the Vue instance
console.log('Hello ' + this.msg + '!') //this is undefined, why????
// `event` is the native DOM event
console.log(event.target.tagName)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment