export default {
methods: {
copy(value) {
try{
const textarea = document.createElement('textarea');
document.body.appendChild(textarea); // 添加到body中
textarea.value = value; // 给dom设置值
textarea.select(); // 设置选中
const copyFalse = document.execCommand('copy', false);
if(copyFalse){
this.alert('复制成功');
}else{
this.alert('复制失败');
}
textarea.remove(); // 用完移除dom
} catch {
this.alert('复制失败')
}
}
}
}