1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| <template> <div style="margin:0 auto;width: 80%"> <el-table :data="dataList"> <el-table-column label="人员名称" prop="name"></el-table-column> <el-table-column label="头像" prop="url"></el-table-column> <el-table-column label="工号" prop="number"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button @click="copyAvatarurl(scope.row)" class="copy">复制头像url</el-button> </template> </el-table-column> </el-table> </div> </template> <script> import Clipboard from 'clipboard'
export default { name: 'copyTest', data () { return { dataList: [ {'name': '小明', 'url': 'https://www.xiaomingtouxiang.com/',number:'9527'}, {'name': '小黑', 'url': 'https://www.xiaoheitouxiang.com/',number:'9526'}, {'name': '小白', 'url': 'https://www.xiaobaitouxiang.com/',number:'9525'} ] } }, methods: { copyAvatarurl (e) { let clipboard = new Clipboard('.copy', { text: function () { return e.avatar } }) clipboard.on('success', e => { this.$message({message: '复制成功', showClose: true, type: 'success'}) clipboard.destroy() }) clipboard.on('error', e => { this.$message({message: '复制失败,', showClose: true, type: 'error'}) clipboard.destroy() }) } } } </script>
|