前端实现复制功能
<span class="el-icon-copy-document icon-text" @click="copyIt(curlName)"></span>
exprot default {
data() {
curlName: 'www.baidu.com'
},
methods: {
// 复制
copyIt(item) {
let oInput = document.createElement("input");
oInput.value = item;
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy"); // 执行浏览器复制命令
oInput.remove();
this.$message({
message: "复制成功",
type: "success",
});
},
}
}