Tag: reader

React – 'Uncaught TypeError:无法读取reader.onload中的属性

当我运行下面的代码 控制台显示: Uncaught TypeError: Cannot read property 'component' of undefined 但testing代码可以显示: ReactDOM.findDOMNode(this.refs.component).innerText = 'ddd'; 什么问题? var reader = new FileReader(); reader.onload = function(e) { console.log('onload: ' + e.target.result); ReactDOM.findDOMNode(this.refs.component).innerText = e.target.result; } reader.onerror = function(stuff) { console.log("error", stuff); console.log (stuff.getMessage()); } ReactDOM.findDOMNode(this.refs.component).innerText = 'ddd'; console.log('readAsText:' + reader.readAsText(data[0]));