js复制文字到剪切板

 document.getElementById('copy').onclick = function () {
      let input = document.createElement('input');
      input.setAttribute('id','input');
      input.value = 'hello';
      document.getElementsByTagName('body')[0].appendChild(input);
      document.getElementById('input').select();
      document.execCommand('copy');
      document.body.removeChild(input);
    }
原文地址:https://www.cnblogs.com/ltog/p/14525647.html