📌  相关文章
📜  将活动类添加到按钮 onclick 反应 - Javascript 代码示例

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

代码示例1
class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      animate: false;
    }

    this.handleClick = this.handleClick.bind(this);
  }

  handleClick(e) {
    // modify the state, this will automatically recall render() below.
    this.setState((prevState) => {
      return { animate: !prevState.animate }
    });
  }

  render() {
    let animationClasses = (this.state.animate ? ' active': '');

    return (
      
    )
  }
}