bool = document.execCommand(aCommandName, aShowDefaultUI, aValueArgument)
<div style={{ width: 220 }}>
<input
id="copy-url"
readOnly="readonly"
style={{ position: "absolute", zIndex: -99, opacity: 0 }}
/>
{text}
<Tooltip placement="topLeft" title="复制此段文本">
<CopyOutlined
style={{ marginLeft: 14 }}
onClick={() => handleCopy(text)}
/>
</Tooltip>
</div>
const handleCopy = (text) => {
let url = document.getElementById("copy-url");
url.value = text;
url.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
message.success("复制成功!");
};