我收到以下错误
未捕获的TypeError:无法读取未定义的属性"setState"
甚至在构造函数中绑定delta之后.
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 1
};
this.delta.bind(this);
}
delta() {
this.setState({
count : this.state.count++
});
}
render() {
return (
<div>
<h1>{this.state.count}</h1>
<button onClick={this.delta}>+</button>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud) 当我使用以小写字母开头的变量时,页面不显示任何内容。如果我将变量名称更改为以大写字母 (HelloWorld) 开头,则页面将显示内容。
<script type="text/jsx">
var helloWorld = React.createClass({
render : function () {
return (
<div>
<h1>Hello World</h1>
</div>
);
}
});
React.render(<helloWorld/> , document.body);
</script>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么会这样?