Create a table from JSON completely dynamically

前端 未结 2 587
囚心锁ツ
囚心锁ツ 2021-01-28 17:41

I want to create entire table from a JSON array include dynamic ths, so a decoupled the head part to:

import React from \'react\';
import TableDataT         


        
2条回答
  •  無奈伤痛
    2021-01-28 18:29

    You need to access the table data using key name as

    let rows = this.props.tableData.map((currElement, index) => {
          return (
          
              { Object.keys(currElement).map((item) =>
              (
                {currElement[item]}
         )
           )}
             
          )
        });
    

提交回复
热议问题