📌  相关文章
📜  如何在 react stackoverflow 中创建一个按钮 - Javascript 代码示例

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

代码示例1
const defaultStyle = {
  width: 100,
  padding: 5,
};

class MultiLevelButton extends React.Component {
  constructor(props) {
    super(props);
    
    this.state = {
      currentState: 0,
    };
    
    this.handleClick = this.handleClick.bind(this);
  }
  
  handleClick() {
    const { currentState } = this.state;
    
    if (currentState < this.props.states.length) {
      this.setState({
        currentState: currentState + 1,
      });
    }
  }
  
  reset() {
    this.setState({
      currentState: 0,
    });
  }
  
  render() {
    const { currentState } = this.state;
    const { states } = this.props;
    
    return (
      
    )
  }
}

const buttonRef = React.createRef();

ReactDOM.render(
  
, document.getElementById('app') );