📌  相关文章
📜  如何通过在 react js 中使用带有多个按钮的 onclick 函数来更改样式类 - Javascript 代码示例

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

代码示例1
/*
 * A simple React component
 */
class Button extends React.Component {   
    constructor(){
    super(); 
    this.state = {
        color_black: true,
      }
    }
    changeColor(){
            this.setState({color_black: !this.state.color_black})
    }
        render(){
        let bgColor = this.state.color_black ? this.props.color : this.props.color2
        return (
        
) } } class Application extends React.Component { render(){ return (
) } } /* * Render the above component into the div#app */ React.render(, document.getElementById('app'));