• React


           <script type="text/babel">
               let colorArr = ["red","yellow","blue","orange","pink","green","gray"];
                 class HelloWorld extends React.Component{
                  constructor(props){
                    super(props);
                    this.state={
                      bgColor:"yellow"
                    };
                    this.toggleColor=this.toggleColor.bind(this);
                     this.changeColor=this.changeColor.bind(this);
                  }
                  
                  
                  toggleColor(){
                    if(this.state.bgColor=="yellow"){
                      this.setState({bgColor:"red"});
                    }else{
                       this.setState({bgColor:"yellow"});
                    }
                  }
                  
                  componentDidMount(){
                      let colorPos = 0;
                      setInterval(()=>{
                          this.setState({bgColor:colorArr[colorPos]});
                          if(colorArr.length-1>colorPos){
                              colorPos++;
                          }else{
                              colorPos=0;
                          }
                          
                      },1000)
                  }
                  changeColor(event){
                      this.setState({bgColor:event.target.value})
                  }
                  render(){
                    console.log(this.props.name);
                    //jsx
                    let objStyle = {background:this.state.bgColor,fontSize:26};
                    return (<div id="jieshao" style={objStyle} onClick={this.toggleColor}>
                             <h3>我叫嘉伟</h3>
                             <input value={this.state.bgColor} onChange={this.changeColor}/>
                         </div>);
                  }
                }
                 let app = document.getElementById("app");
                ReactDOM.render(<HelloWorld
                name="fat" color="yellow"/>,app);
  • 相关阅读:
    bzoj2732[HNOI2012]射箭
    poj1474 Video Surveillance
    bzoj3167[HEOI2013]SAO
    hdu2296 Ring
    bzoj2119 股市的预测
    bzoj2244[SDOI2011]拦截导弹
    bzoj3502[PA2012]Tanie Linie(最大k区间和)
    vijos1859[TJOI2014]电源插排
    比较SQL查询性能 语句
    什么是高内聚低耦合
  • 原文地址:https://www.cnblogs.com/10manongit/p/12219101.html
Copyright © 2020-2023  润新知