React - '未捕获的TypeError:无法读取reader.onload中的属性

时间:2015-11-24 07:26:44

标签: javascript node.js reactjs reader

当我在下面运行代码时

控制台显示:

Uncaught TypeError: Cannot read property 'component' of undefined

但测试代码可以显示:

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]));

0 个答案:

没有答案