我正在尝试遵循pluralsight教程来开始使用react js。 本教程的重点是单击按钮会导致按钮的值增加。我按照教程中的人的确切代码进行操作,但我无法弄清楚为什么按钮不会增加。这是link to the plunk for this tutorial.
我的猜测是我的可能有问题
handleClick: function(){
this.setState({ counter: this.state.counter+1 });
},
功能?
最佳答案
你的
onclick
应该是
onClick
相反。
改变它,它应该可以工作。
此外,您可能想使用
ReactDOM.render
而不是
React.render
引用这个https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
关于javascript - 按照教程时 react 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33404940/