复制文案的兼容写法
1. 兼容写法
// 兼容写法
async handleCopyUserLink() {
try {
// 优先使用现代 API
await navigator.clipboard.writeText("我是要复制的内容");
this.$message.success('复制成功');
} catch (err) {
// 降级方案(execCommand 已经逐渐被弃用)
this.$refs.copy.select();
document.execCommand('copy');
this.$message.success('复制成功');
}
}