이 문맥에서 'this'의 의미에 대한 설명을 찾고 있습니다. 왜 Ajax 요청 후에 'this'를 콜백에 바인딩해야합니까? 디버거를 확인할 때 바인드 여부를 '생성자'에 바인드되는지 여부를 'this'라고합니다. 기본적으로이 this
가 가리 때문이다componentDidMount()에서 'this'의 의미, ReactJS
var BugList = React.createClass({
getInitialState: function() {
return {
bugs: []
}
},
componentDidMount: function() {
$.ajax('/api/bugs').done(function(data) {
this.setState({
bugs: JSON.parse(data)
});
}.bind(this));
},
관련 : http://stackoverflow.com/questions/6889855/jquery-ajax-success-doesnt-work-with-this?noredirect=1&lq=1 –
관련 : http://stackoverflow.com/a/33381852/2733506 –
* "디버거를 검사 할 때 바인드 여부에 관계없이 'this'가 생성자에 바인딩됩니다. * -이게 무슨 의미인가요? 예제에는 생성자가 없습니다. 'this'의 바인딩? – Aaron