React technology develops backend management system
The function to be implemented is to click the copy icon and copy the following ID
First, introduce copy
import copy from 'copy-to-clipboard';
Then define the method
const spanRef = useRef(null);
function handleCopyClick() {
const textToCopy = spanRef.current.innerText;
copy(textToCopy);
message.success('复制成功!');
}
and then call the method
<div onClick={handleCopyClick} >
<div ref={spanRef}><CopyTwoTone />{item.meetingId}</div>
</div>
The front-end implementation effect is as shown below