0
我想显示一个列表,其中包含我的数组任务的值。使用无状态组件显示值列表
当我检查的页面,去安慰我看到这一点:
Uncaught SyntaxError: embedded: Unexpected token (4:30)
我不知道什么能可能出错的想法,但我的代码看起来像下面这样:
<script type="text/babel">
var TaskList = React.createClass({
getInitialState: funtion(){
return {
tasks: [
{title: 'Clean dishes', id: 1},
{title: 'Take out the trash', id: 2},
{title: 'Wash the dishes', id: 3}
]
}
},
render: function(){
return(
<ul>
{this.state.tasks.map(function(task){
return <Task title={task.title} />
}
)}
</ul>
)
}
});
var Task = function(props){
return(
<li>Task: {props.title}</li>
)
};
ReactDOM.render(
<TaskList />,
document.getElementById('app')
)
</script>
希望你能帮助。