我试图使 accordion 表使用引导程序与jsx的React,但它显示折叠的文本在开始也点击功能将不工作。我试图转换div的例子到表,但不能想出我应该如何转换多个div到表的设计。它
{props.users.map((user, i) => (
<Fragment>
<tr key={i} className="accordion-button" data-bs-target={"#Collapse" + i} aria-expanded="true" data-bs-toggle="collapse" aria-controls={"collapse" + i} >
<th scope="row">{user.id}</th>
<td>{user.name}</td>
<td>{user.mail}</td>
<td>{user.contact}</td>
<td><Link type="button"
to={`edit/${user.id}`}
className="btn btn-md btn-outline-primary"
>Edit</Link></td>
<td><button className="btn btn-md btn-outline-danger" data-target={i} onClick={(event) => props.deleteUserProp(user)}>Delete</button></td>
</tr>
<tr id={"Collapse" + i} className="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent={"#accordionExample" + i}>
<td colSpan="6" className="accordion-body">
<strong>This is the {i} item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</td>
</tr>
</Fragment>
))}
1条答案
按热度按时间8i9zcol21#
我不知道我还需要导入bootstrap的js库,添加了下面的代码后,就可以了。
“/节点模块/引导/js/源/折叠. js”;