📜  设置计量图标颜色更改 onClick 反应 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:59.905000             🧑  作者: Mango

代码示例1
class Utilitybar extends React.Component {
  constructor(props) {
    super(props)
    this.onButtonClicked = this.onButtonClicked.bind(this)
    this.state = { currentButton: null }
  }

  onButtonClicked (id) {
    this.setState({ currentButton: this.state.currentButton === id ? null : id })
  }

  render(){
    return (
      
this.onButtonClicked(0)}> this.onButtonClicked(1)}>
); } }