util.copyText = function (text) {

  var textArea = document.createElement("textarea");
  // textArea.style['display']='none'
  textArea.style['position'] = 'absolute'
  textArea.style['top'] = '0'
  textArea.style['left'] = '0'
  textArea.value = text;
  document.body.appendChild(textArea);
  textArea.focus();
  textArea.select();

  try {
    var successful = document.execCommand('copy');
    var msg = successful ? 'successful' : 'unsuccessful';
  } catch (err) {
    console.error('Fallback: Oops, unable to copy', err);
  }

  document.body.removeChild(textArea);
};

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2021-12-03
  • 2021-09-01
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案