1
방법 아래
var DBBox = React.createClass({
loadArticlesFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
data: {username:data.username,isPublished:data.isPublished, heading:data.heading},
cache: false,
success: function(data) {
this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
를 잘 작동하지만 메소드 선언을 변경하면이
loadArticlesFromServer:()=> { //error - Cannot read property 'props' of undefined at line 6
또는
loadArticlesFromServer=()=> { //Syntax error
암과 같은 라인 2 기능, 화살표 나는 화살 기능을 잘못 사용했거나 누락 되었습니까? 아니면 지원되지 않습니까? 나는 크롬을 사용하고 행운없이 조화의 깃발을 가능하게하려고 노력했다.
화살표 기능에서 'this'의 동작을 연구해야합니다. 화살표로'bind'를 사용할 수 없습니다. – Redu
[이 질문을 참조하십시오] (http://stackoverflow.com/questions/31647507/this-values-for-arrow-functions) – qxz
감사합니다 @ 리두, 올바른 방향으로 나를 가리켰다. –