js vue 点击按钮复制数据到剪贴板

copyCardNumber (target) { // 按钮点击事件
  let that = this
  const save = function (e) {
    e.clipboardData.setData('text/plain', that.list)  // that.list=['苹果', '梨子', '香蕉']
    e.preventDefault();
  }
  document.addEventListener('copy', save);
  document.execCommand('copy');
  that.$Message.warning('复制成功')
}

// 粘贴或者组合键Ctrl+v内容: 苹果, 梨子, 香蕉

你可能感兴趣的:(javascript,vue.js,前端)