Angular2 + Typescript + FileReader.onLoad = property does not exist

前端 未结 2 1257
情深已故
情深已故 2021-02-12 14:52

I am using the FileReader Interface and it’s asynchronous method readAsText() to read a local text file, After that when the onload ev

2条回答
  •  走了就别回头了
    2021-02-12 15:23

    If you want to use this inside the callback, use an arrow function, otherwise it won't work

    reader.onload = (e) => {
        this.text=reader.result;
    }
    

    https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

提交回复
热议问题