我试图习惯于在反应中道具,但我不从本地主机获得响应

时间:2020-03-23 13:32:34

标签: reactjs redux components

我试图习惯于用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"));

0 个答案:

没有答案