0

Why do we use this keyword to emit an event?

this.$emit('myEvent')
Ali
  • 39
  • 6
  • Um, because you're emitting an event? Why would you use any other name? – Robert Harvey Jan 20 '19 at 20:54
  • @RobertHarvey Why we can't use simply `$emit('myEvent')` without `this`? – Ali Jan 20 '19 at 20:57
  • [Understand JavaScript’s “this” With Clarity, and Master It](https://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/) – Robert Harvey Jan 20 '19 at 21:11
  • When used inside of a Vue object, ```this``` refers to the Vue object. You don't need to use ```this``` inside of the html inside of your .vue files because the Vue will look inside of your Vue object. For example, you would just use ```$emit('myEvent')``` inside of a tag like ``````. – Brett Fisher Jan 20 '19 at 23:08

0 Answers0