文章复制功能

80 阅读1分钟
<el-table-column label="地址" show-overflow-tooltip> <template slot-scope="scope">
  <div ref="textDom" @click="copyText(scope.row.url)" style="cursor: pointer" title="点击可复制" > {{ scope.row.url }} </div> 
<textarea ref="inputDom" class="inputDom">我是替身</textarea> </template> 
</el-table-column> 
// 点击文本复制功能 
  copyText(value) { 
    this.$nextTick(() => {
    this.$refs.inputDom.value = value this.$refs.inputDom.select() //选中文本      }) 
    document.execCommand('Copy') // 执行浏览器复制命令 
    this.$message.success('复制成功')
   } 
    
 .inputDom { cursor: pointer; opacity: 0; position: absolute; }