javascript - .map 元素中的 Href 或链接,其中包含道具和子元素
问题描述
我有数据将使用 .map 函数填充并显示在表结构中
我想要什么?
我想让每个元素都成为可点击的链接。这样对应的产品就会在新标签页中打开
这是一段代码
<div className="product-section">
<div className="card-body">
<div className="table-scroll">
<table
className={
sortSelectedCategorySetAttributes.length > 1
? "table table-striped table-borderless"
: "column-noscroll"
}
style={{ marginTop: "0px" }}
>
<thead>
<tr>
<th className="sticky-fix">PRODUCT</th>
{sortSelectedCategorySetAttributes &&
sortSelectedCategorySetAttributes.map((attributes, index) => {
return (
<th style={fixedHeader} key={index}>
{" "}
{attributes && attributes.name.toUpperCase()}
</th>
);
})}
</tr>
</thead>
{console.log(rowData)}
<tbody>
{rowData.map(ele => {
return <a href={ele.key}>{ele}</a>;
})}
</tbody>
</table>
</div>
</div>
</div>;
解决方案
推荐阅读
- uwp - 如何从 UWP C# 中的 SoftwareBitmap 获取像素数据?
- r - 如何在不同的几何图形中具有相同的美学(颜色)不同的比例?
- maven-2 - 当执行 MVN INSTALL 时,CPU 变高并导致 PC 关机
- node.js - Page.evaluate() 返回未定义,但语句在 Chrome devTools 中有效
- aurelia - 如何使用 aurelia 生成和扫描条形码?
- oracle - ORA-001031从存储过程执行语句时权限不足
- python-3.x - 如何避免使用 pip install -e
每次我 git pull 更新 ? - android - 模棱两可的 Firebase 分析控制台错误
- protractor - 如何修复“错误:getaddrinfo ENOTFOUND selenium-release.storage.googleapis.com selenium-release.storage.googleapis.com:443”
- ruby-on-rails - Ruby on Rails 添加评论以发表