0
我想用django namedtuple
做一個表,但得到一個錯誤。標題(這是列表)雖然工作正常。與django namedtuple反應表返回.map不是一個函數
views.py
:
info = [Info(id=5, location_id=861, f=None),Info(id=3, location_id=650, f=None)]
return render('index.html', {'info': info})
index.html
var headers = ['id', 'location', 'f']
var Table = React.createClass({
render: function() {
return (
<table className="table-hover">
{this.props.headers.map(function(name, index) {
return <th key={ index }>{name}</th>;
})};
{this.props.tableContent.map(function(row, index) {
<tr key={index}>
return(
{row.map(function(col, i) {
<td key={i}>{col}</td>
})}
);
</tr>
})};
</table>
)
}
});
ReactDOM.render(
<Table headers={headers} tableContent={info}/>,
document.getElementById('content')
);
我看不到任何輸出和控制檯說:Uncaught TypeError: this.props.tableContent.map is not a function
。