react copy content to clipboard

1. Download the corresponding package react-copy-to-clipboard

npm install --save react-copy-to-clipboard

2. Import and use the page

import { CopyToClipboard } from 'react-copy-to-clipboard';

3. Use directly

<CopyToClipboard text={"https://www.baidu.com/"}
    onCopy={() => message.success('复制成功~')}>
    <Button type="primary"  shape="round" size='small' ghost>
        点击复制
    </Button>
</CopyToClipboard>

Guess you like

Origin blog.csdn.net/weixin_45369856/article/details/128384969