import React, { Component } from 'react';
import './reactCss.css'
class App extends Component {
constructor(props) {
super(props)
this.state = {
list: ['111', '222', '3333'],
current: 0
}
}
render() {
return (
<div >
<ul>
{
this.state.list.map((v, i) => {
return <li className={this.state.current === i ? 'active' : ''} key={i} onClick={this.changColor.bind(this, i)}>{v}</li>
})
}
</ul>
</div>
)
}
changColor = (i) => {
console.log(i)
this.setState({
current: i
})
}
}
export default App;