- 安装npm install–save vue-clipboard2
- 在mian.js中进行注册
import VueClipBoard from ‘vue-clipboard2’
Vue.use(VueClipBoard) - el-table标签中绑定点击事件 @cell-click=“(row, column) => copyList({column})”
- el-table-column中添加icon并绑定点击事件
<template slot="header">
<span>弹框uv数
<i
class="el-icon-copy-document"
style="color:#fff;cursor:pointer;"
@click="copyList('uvcount')"
/>
</span>
</template>
copyList(value){
let str=""
this.tableData.forEach(item=>{
str += item[value]+'\n'
})
this.copyAppid(str)
},
copyAppid(str) {
this.$copyText(str).then( (e) => {
this.$message.success('复制成功')
}, (e) => {
this.$message.error('复制失败!')
})
},
版权声明:本文为joy_1004原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。