【发布时间】:2019-11-30 22:27:48
【问题描述】:
Reactstraps 卡片和折叠似乎不起作用。我不知道我做错了什么,但我尝试了几种不同的方法都无济于事。文本就在那里,按钮什么也不做。
我尝试过 reactstrap、react bootstrap 和普通的 html 代码。我正在使用 rekit ide 来处理这个项目。
import React, { Component } from 'react';
import { Collapse, Button, CardBody, Card } from 'reactstrap';
class Example extends Component {
constructor(props) {
super(props);
this.toggle = this.toggle.bind(this);
this.state = { collapse: false };
}
toggle() {
this.setState(state => ({ collapse: !state.collapse }));
}
render() {
return (
<div>
<Button color="primary" onClick={this.toggle} style={{ marginBottom: '1rem' }}>Toggle</Button>
<Collapse isOpen={this.state.collapse}>
<Card>
<CardBody>
Anim pariatur cliche reprehenderit,
enim eiusmod high life accusamus terry richardson ad squid. Nihil
anim keffiyeh helvetica, craft beer labore wes anderson cred
nesciunt sapiente ea proident.
</CardBody>
</Card>
</Collapse>
</div>
);
}
}
export default Example;
当我按下按钮时,我应该得到一张折叠卡片,但我什么也没得到。
【问题讨论】:
标签: javascript node.js reactjs reactstrap