import clipboardCopy from 'clipboard-copy';
const handleCopyClick = async () => {
const profitList = [];
const CostList = [];
projectTable.map((el) => {
profitList.push(Number(el.todayProfit / 10000).toFixed(2));
CostList.push(Number(el.todayProfit / 10000).toFixed(2));
});
const arraysText = `profit_list = [${profitList.join(
', ',
)}]\ncost_list = [${CostList.join(', ')}]`;
try {
await clipboardCopy(arraysText);
message.success('复制成功');
} catch (error) {
console.error('复制失败:', error);
}
};
<Form.Item>
<Button type="primary" onClick={handleCopyClick}>
一键复制
</Button>
</Form.Item>
点击按钮复制
最新推荐文章于 2024-07-23 14:51:29 发布