constructor() {
super();
this.state = {
activeCollapse: 'classify'
}
}
handleExpandCollaps = (name) => {
if (this.state.activeCollapse === name) {
this.setState({ activeCollapse: '' })
} else {
this.setState({ activeCollapse: name })
}
}
{/* 分类 */}
<li className={`${this.state.activeCollapse === "classify" ? 'active' : ''}`} onClick={() => this.handleExpandCollaps("classify")} data-id="classify">
<a className='auto'>
<span className='pull-right text-muted'>
<i className='fontello icon-fw fontello-angle-right text'></i>
<i className='fontello icon-fw fontello-angle-down text-active'></i>
</span>
</a>
</li>
{/* 页面 */}
<
React实现组件收缩展开功能
于 2022-03-19 15:51:48 首次发布