简单点击复制内容

copy(data) {
      const input = document.createElement('input')
      document.body.appendChild(input)
      input.setAttribute('value', data)
      input.select()
      if (document.execCommand('copy')) {
        document.execCommand('copy')
        this.$message({
          showClose: true,
          message: '复制成功',
          type: 'success'
        })
      }
      document.body.removeChild(input)
    }
posted @ 2021-08-27 16:39  技术渣渣Z  阅读(48)  评论(0编辑  收藏  举报