javascript 如何在反应中迭代数组?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 如何在反应中迭代数组?相关的知识,希望对你有一定的参考价值。
import React from 'react'
const cpTable = (props) => {
let trThead = null
let trTbody = null
if (props.data.rowContent){
trThead = (
props.data.rowContent.map( rowContent => {
return (
<tr>
{
Object.keys(rowContent).map(key => {
return <th>{rowContent[key]}</th>
})
}
</tr>
)
})
)
trTbody = (
<tr>
<td>The table body</td>
</tr>
)
}
return (
<div className="table-responsive">
<h1>{props.data.title}</h1>
<table className="table table-striped table-bordered">
<thead>
{trThead}
</thead>
<tbody>
{trTbody}
</tbody>
</table>
</div>
)
}
export default cpTable
以上是关于javascript 如何在反应中迭代数组?的主要内容,如果未能解决你的问题,请参考以下文章