我试图习惯于用props反应,但是我没有从本地主机获得响应
class Football extends React.Component {
constructor(props) {
super(props);
this.shoot = this.shoot.bind(this);
}
shoot() {
alert(this);
/*
Thanks to the binding in the constructor function,
the 'this' keyword now refers to the component object
*/
}
render() {
return <button onClick={shoot}>Take the shot!</button>;
}
}
ReactDOM.render(<Football />, document.getElementById("root"));