ES6 functions, arrow functions and 'this' in an ES6 class [duplicate]
问题 This question already has answers here : Should I write methods as arrow functions in Angular's class (3 answers) Arrow vs classic method in ES6 class (1 answer) Closed last year . class App extends Component { constructor(props) { ... } onChange = (e) => this.setState({term: e.target.value}) onSubmit(e){ e.preventDefault(); const api_key = "C1hha1quJAQZf2JUlK"; const url = `http://api.giphy.com/v1/gifs/search?q=${this.state.term}&api_key=${api_key}`; } render() { return ( <div> <form