我正在從React.js組件狀態的教程做一些練習。我必須做編輯,刪除和保存按鈕到文檔和textarea。我正在嘗試做,但我的瀏覽器顯示爲空屏幕。我的代碼:我有React.js狀態的一些問題
<html>
<head>
<script src = "react-master/../js/react.js"></script>
<script src = "react-master/../js/react-dom.js"></script>
<script src = "js/browser.js"></script>
</head>
<body>
<div id = "example"></div>
<script type = "text/babel">
var Comment = React.createClass({
getInitialState: function(){
return {editing: false}
},
edit: function(){
this.setState({editing: true});
},
remove: function(){
console.log("Removing comments");
},
save: function(){
this.setState({editing: false});
},
renderNormal: function(){
return(
<div className = "comment-container">
<div className = "comment-text">{this.props.children}</div>
<button onClick = {this.edit}>Edit</button>
<button onClick = {this.remove}>Remove</button>
</div>
);
},
renderForm: function(){
return(
<div className = "comment-container">
<teaxtarea defaultValue = {this.props.children}></teaxtarea>
<button onClick = {this.save}>Save</button>
</div>
);
},
render: function(){
if (this.state.editing){
return this.renderForm;
}else{
return this.renderNormal;
}
}
});
ReactDOM.render(
<div className = "board">
<Comment>Hey now</Comment>
<Comment>Hey Anja</Comment>
<Comment>Hey Olga</Comment>
</div>,
document.getElementById("example"));
</script>
我犯了什麼錯誤?