繁体   English   中英

click 不能在反应中的可折叠引导表上工作

[英]click won't work on collapsible bootstrap table in react

我尝试使用引导程序制作手风琴表,对 jsx 做出反应,但它在开始时显示折叠的文本,点击 function 也不起作用。 我试图将 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>
                ))}

不知道还要导入bootstrap的js库。 在我添加下面的代码后,它工作了。

“/node_modules/bootstrap/js/src/collapse.js”;

暂无
暂无

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

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