代码如下:
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button type="text" @click="handleCopy(scope.$index, scope.row)">复制链接</el-button>
<el-button type="text" >删除</el-button>
</template>
</el-table-column>
methods:{
handleCopy(index, row) {
this.copyData = row.name;
console.log(row)
this.copy(this.copyData);
},
copy(data) {
let url = data;
let oInput = document.createElement("input");
oInput.value = url;
document.body.appendChild(oInput);
oInput.select(); // 选择对象;
console.log(oInput.value);
document.execCommand("Copy"); // 执行浏览器复制命令
this.$message({
message: "复制成功",
type: "success",
});
oInput.remove();
},
}
出处:https://www.cnblogs.com/zyz-s/p/11636885.html