Class component event bindingimport React from 'react'; import ReactDOM from 'react-dom'; class App extends React.Component { handleClick() { console.log(111); } render() { return (<button onClick={this.handleClick} > Click me</button >) } } ReactDOM.render(<App />, document.getElementById('root')) Function component event bindingimport React from 'react'; import ReactDOM from 'react-dom'; function App() { function handleClick() { console.log(111); } // There is no this in the function component, so just write the function name without adding this. return (<button onClick={handleClick}>Click me</button>) } ReactDOM.render(<App />, document.getElementById('root')) SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: 9 Practical CSS Properties Web Front-end Developers Must Know
>>: MySQL series tutorials for beginners
Table of contents Preface 1. Install Docker 2. In...
Linux is generally used as a server, and the serv...
I believe everyone has used JD. There is a very c...
Say it in advance We all know that Docker can ach...
Table of contents 1 Node.js method of sending ema...
This article example shares the specific code of ...
1. Brigde——Bridge: VMnet0 is used by default 1. P...
Recently, the company has put forward a requireme...
What is a Viewport Mobile browsers place web page...
Docker installation Use the official installation...
1. First of all, we need to distinguish between t...
Table of contents 1. Introduction to SQL Injectio...
Table of contents 1. Anonymous slots 2. Named slo...
Table of contents Start by clicking the input box...
Table of contents vue2.x vue3.x tiny-emitter plug...