constructor(props) {
super(props);
this.switchClick = this.switchClick.bind(this);
this.state = {
headSwitch: true
};
}
switchClick () {
//怎么区分执行switchClick()的是哪个节点
this.setState({
headSwitch: !this.state.headSwitch
});
}
render() {
return (
<div className="head-switch">
<a className={this.state.headSwitch ? 'act' : ''} onClick={this.switchClick}>1</a>
<a className={this.state.headSwitch ? '' : 'act'} onClick={this.switchClick}>2</a>
</div>
)
}
慕容3067478
相关分类