const textarea = document.createElement('textarea') as any;
textarea.readOnly = 'readonly';
textarea.style.position = 'absolute';
textarea.style.left = '-9999px';
// 将要 copy 的值赋给 textarea 标签的 value 属性
textarea.value = this.data.pdf;
// 将 textarea 插入到 body 中
document.body.appendChild(textarea);
// 选中值并复制
textarea.select();
textarea.setSelectionRange(0, textarea.value.length);
const result = document.execCommand('Copy');
if (result) {
this.$message.success('链接复制成功')
}
document.body.removeChild(textarea);
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论