简体   繁体   English

我想在反应中创建一个类似结构的网状表

[英]I want to create a meshed table like structure in react

I am creating a page where I need to show a table having rows and columns like structure and also need to add numbers inside the cells in the table.我正在创建一个页面,我需要在其中显示具有类似结构的行和列的表格,并且还需要在表格的单元格内添加数字。 It has width and height also for the designing perspective.从设计的角度来看,它也有宽度和高度。

But I have no idea how to implement the structure in react.但是我不知道如何在反应中实现结构。

I am adding a prototype of what I have to create in my project.我正在添加我必须在我的项目中创建的原型。

表格图片

What should be the best way to implement this so that I can able to show the colors and numbers.最好的实现方式应该是什么,以便我能够显示 colors 和数字。

You can use a table你可以用一张桌子

const rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

<table>
  {rows.map(cells => {
    return (
      <tr>
        {cells.map(cellData => <td>{cellData}</td>)}
      </tr>
     );
  })}
</table>

Or use divs, if you don't need a table.如果不需要表格,也可以使用 div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM