0
JSX代碼這裏:陣營組件 - 設置頁面標題
class PaperList extends React.Component{
constructor() {
super();
this.state = {
newsList: [{
title:'title1',
content:'content1'
},{
title:'title2',
content:'content2'
}]
};
}
render() {
var that = this;
var lists = this.state.newsList.map(function(news,idx){
return <Paper key={idx} style={paperStyle} zDepth={2}><h2>{that.state.newsList['+idx+'].title}</h2></Paper>;
});
return (<div>
{lists}
</div>
);
}
如果只有that.state.newsList [ '+ IDX'],是沒有問題的。 如何獲得標題?