简单实现复制到剪切板

参考: Cut and Copy Commands

const selection = window.getSelection();

if (selection.rangeCount > 0) {
  selection.removeAllRanges();
}

const range = document.createRange();
range.selectNode(yourHtmlElement);

selection.addRange(range);

document.execCommand('copy');
Comments
Write a Comment