Last active
January 24, 2018 17:30
-
-
Save matthieu-D/f3aefe9a3a25d1d6fa14c493cb5b2768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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