慕桂英546537
2018-12-20 18:15:06
就是下面這個(gè),最開始點(diǎn)擊1,然后在點(diǎn)擊2,然后在點(diǎn)擊2說一下大概具體思路就行,當(dāng)然有代碼更好,這個(gè)列表是遍歷出來的- -
1 回答

慕少森
TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊
import classNames from 'classnames';
constructor(props) {
super(props);
this.state = {
...
index: 0,
};
}
handleClick (index) {
// toggle效果你可以先判定是否等同,然后設(shè)置為-1
this.setState({index});
}
render() {
some.map((item ,idx) => {
return (
<li className={ classNames({active: idx === this.state.index}) } onClick={ this.handleClick.bind(this, idx) }></li>
)
})
}
添加回答
舉報(bào)
0/150
提交
取消