0

In my Vue mounted code, I am calling a function test via this.getFile(file). This works fine as intended.

When however I am calling this.display(text) from the function of mounted, I am getting an error

this.display is not a function

I understand that this is because the this there is now pointing to the their parent. What I do not understand is what I should use there instead. Removing the this also gives an error.

I have the following Vue code

      mounted() {
        let reader = new FileReader();
        reader.onload = evt => {
          const text = evt.target.result
          this.display(text)
        };
      },
      methods: {
        display(text){
          console.log('this is test', text)
        }
      }
BESTAssist
  • 11
  • 2

0 Answers0