Skip to content
Advertisement

this.$emit is not a function inside file reader onload

I know about lexical scope that this keyword is pointing to the window and not Vue

But how do I make it point to Vue?

What I am trying to do is get csv data and parse it, I’m using d3 to parse the data it’s working fine, I am just unable to emit the event with the data because of the scope issue

JavaScript

Advertisement

Answer

change the reader.onload line to the below to keep lexical scope for the this keyword

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement