洛上千栀
2019-06-26 15:37
//正确
class TodoItem extends React.Component{
render(){
return(
<div>{this.props.content}</div>
)
}
}
//错误(这个写法是现在版本脚手架示例里面的)
function TodoItem (){
return(
<div>{this.props.content}</div>
)
}
函数组件的props是用传入的参数来表示的。
function TodoItem(props) {
return (
<div>{props.content}</div>
)
}
React16.4 快速上手
40364 学习 · 137 问题
相似问题