BackgroundIn a list like the one below, clicking the Delete button requires the delete operation to be performed List generation: { title: 'Operation', dataIndex: 'rowguid', key: 'rowguid', render: (text, record) => ( <Space size="middle"> <Button type="primary" size="small" >Modify</Button> <Button type="danger" size="small" >Delete</Button> </Space> ) } I need to add an event when rendering and generating the delete button, and call it when it is clicked, and also pass parameters. This parameter I started by writing: But the problem is that the delByGuid function is executed when the page is loaded, and the output of our console is: Not only that, when I clicked the delete button, the function was not executed. It seems that this is not allowed. question:1. Executed when the page is rendered 2. Click the button, onclick is not executed Solution:{ title: 'Operation', dataIndex: 'rowguid', key: 'rowguid', render: (text, record) => ( <Space size="middle"> <Button type="primary" size="small" >Modify</Button> <Button type="danger" size="small" onClick={(e)=>delByGuid(text)}>Delete</Button> </Space> ) } onClick={(e)=>delByGuid(text)} This solves the problem. It doesn't work when the page is loaded, but it can be called when it is clicked. This is the end of this article about React onClick passing parameters. For more relevant React onClick passing parameters content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Implementation of docker-compose deployment project based on MySQL8
>>: Detailed deployment steps for MySQL MHA high availability configuration and failover
Copy code The code is as follows: <div class=&...
This article shares with you how to install Kylin...
Configuration Instructions Linux system: CentOS-7...
Specify in CSS style file #class td /*Set the tab...
Table of contents 1. Background of WAF 2. What is...
Will mysql's IN invalidate the index? Won'...
The utf8mb4 encoding is a superset of the utf8 en...
1. What is floating? Floating, as the name sugges...
Table of contents MySQL Truncate usage 1. Truncat...
Introduction The meta tag is an auxiliary tag in ...
Flex(彈性布局) in CSS can flexibly control the layout...
Preface The mysql module (project address is http...
Table of contents 1. props 2..sync 3.v-model 4.re...
1. Check whether port 80 is occupied. Generally, ...
mysqladmin is an official mysql client program th...