方式一:ES6
安装
npm i --save copy-to-clipboard
1
示例
import copy from 'copy-to-clipboard';
copy('Text');
1
2
3
方式二:CDN
https://unpkg.com/copy-to-clipboard@3.3.1/example/index.js https://cdn.jsdelivr.net/npm/copy-to-clipboard@3.3.1/example/index.js
下载
wget http://sudodoki.name/copy-to-clipboard/example/index.js -O copy-to-clipboard.min.js
<script src="./copy-to-clipboard.min.js"></script> <script type="text/javascript"> copyToClipboard('Text'); </script>