React 复制插件使用(npm i react-copy-to-clipboard)

颛孙天宇
2023-12-01
import { CopyToClipboard } from 'react-copy-to-clipboard';

<CopyToClipboard 
    text={haggleStore.extension.extensionUrl} 
    onCopy={() => this.handleCopy(haggleStore.extension.extensionUrl)}>
    <span>复制地址</span>
</CopyToClipboard>

// 复制链接
handleCopy = url => {
    if (!url) return false;
    noticeStore.setLastError({ effect: 2, tip: '复制成功' });
};




 类似资料: