如何在react/js中将数组显示为表中的单列



我正在尝试验证excel工作表中所需列的null值,并尝试将结果显示为一个表,其中列为-行号,null值列名。

由于一行中的许多列可能具有null值,因此我将这些列存储为一个数组。

在表中显示它时,我无法在元素中获取逗号分隔符。

关于如何在表中的单列abc中显示具有逗号分隔符(如[a,b,c,--](的数组,有什么建议吗?

Presenting a sample code base 
export default function App() {
const names = ["a", "b","c"];
return (
<div className="App">
<table>
<thead>
<th>Names</th>
</thead>
<tbody>
<td>{names}</td>
</tbody>
</table>
</div>
);
}
This is giving output as 
名称
abc

您可以使用分隔符加入数组,在这种情况下,它应该是,

CODESANDBOX

export default function App() {
const names = ["a", "b", "c"];
return (
<div className="App">
<table>
<thead>
<tr>
<td>Names</td>
</tr>
</thead>
<tbody>
<tr>
<td>{names.join(",")}</td>
</tr>
</tbody>
</table>
</div>
);
}

最新更新