加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在react中实现一个table切换?

发布时间:2020-12-15 20:27:34 所属栏目:百科 来源:网络整理
导读:废话不说,直接贴代码,供新手参考 export default class TabComponent extends Component { constructor(props){ super(props); this.state = { };}render(){ return ( TabController div name="one" 第一部分 /div div name="two" 第二部分 /div div name=

废话不说,直接贴代码,供新手参考

export default class TabComponent extends Component {
constructor(props){
super(props);
this.state = {

};
}
render(){
    return (
        <TabController>
            <div name="one">
                第一部分
            </div>
            <div name="two">
                第二部分
            </div>
            <div name="three">
                第三部分
            </div>
        </TabController>
    );
}

}

上面是一个组件

constructor(props) {
super(props);
this.state = {
coutype: 0
}
}
itemNav = (index) => {
return index === this.state.coutype ? ‘active‘ : ‘‘;
}

    { this.state.couponBar.map((element,index) => { return (
  • { this.setState({ coutype: index }) } } className={ this.itemNav(index) } key={index}>{ element }
  • ) }) }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读