版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
点击调用函数
copy = obj => {
if (!document.queryCommandSupported('copy')) {
throw new Error('document.execCommand method not support copy command');
}
const input = document.createElement('input');
input.style.cssText = 'display: block;opacity: 0;position: absolute;left: -10000px;top: -10000px;z-index: -1;width: 1px;height: 1px;'
document.body.appendChild(input);
input.value = obj;
input.select();
document.execCommand('copy');
document.body.removeChild(input);
message.success('复制成功');
};