const Copy = function (str) {
var save = function (e) {
e.clipboardData.setData('text/plain', str);
e.preventDefault();
};
document.addEventListener('copy', save);
document.execCommand('copy');
document.removeEventListener('copy', save);
console.log('复制成功');
notification.open({
message: '复制成功了哦!',
icon: <SmileOutlined style={{ color: '#108ee9' }} />,
});
}
使用: Copy(txt)
文章评论