之前只能用flash来粘贴,太麻烦。
github就不用flash也能粘贴,参考例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Copy测试页面</title>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
</head>
<body>
<!-- Target -->
<input id="foo" value="https://github.com/zenorocha/clipboard.js.git">
<!-- Trigger -->
<button class="btn" data-clipboard-target="#foo">
Copy to clipboard
</button>
<script>
new ClipboardJS('.btn');
</script>
</body>
</html>