Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Last active January 24, 2018 17:30
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 matthieu-D/f3aefe9a3a25d1d6fa14c493cb5b2768 to your computer and use it in GitHub Desktop.
Save matthieu-D/f3aefe9a3a25d1d6fa14c493cb5b2768 to your computer and use it in GitHub Desktop.
<template>
<div>
<div @click="showFirstThis()">Show current this object</div>
<div @click="showSecondThis()">Show global this object</div>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
},
methods: {
// Careful of () =>
showFirstThis: function() {
console.log('Basic function', this);
},
showSecondThis: () => {
console.log('Fat arrow', this);
}
}
}
</script>
<style>
div {
width: 100%;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment