React

事件对象: 

import React,{Component} from ‘react‘

class Index extends Component{
    constructor(props){
        super(props)
        this.state = {
            msg:‘张学友‘
        }
    }
    getMsg=(event)=>{
        alert(this.state.msg);
    event.target.value;//获取值
    console.log(event.target); //获取当前Dom节点 event.target.style.background = ‘red‘ ; //改变当前Dom的背景色      
        console.log(event.target.getAttribute(‘aid‘)); //获取当前Dom属性

    }
    setMsg=()=>{
        this.setState({
            msg:‘刘德华‘
        })
    }
    render(){
        return(
            <div>
                {this.state.msg}
                <button aid=‘1111‘ onClick={this.getMsg}>点击获值</button>
                <br />
                <button onClick={this.setMsg}>改变值</button>
            </div>
        )
    }
}
export default Index