项目场景
点击分享按钮,将复制分享链接
解决方法
<el-button
size="small"
type="primary"
@click="copyAddress"
>分享</el-button>
copyAddress() {
let oInput = document.createElement("input");
oInput.value = '复制内容';
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
oInput.remove();
this.$message({
message: "复制成功",
type: "success",
});
},