官网

http://www.clipboardjs.cn/

 

引入

<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>

 

使用方式

例如:

从属性复制文本

<button class="btn" data-clipboard-text="Just because you can doesn't mean you should — clipboard.js">
    Copy to clipboard
</button>

事件

var clipboard = new ClipboardJS('.btn');

clipboard.on('success', function(e) {
    console.info('Action:', e.action);
    console.info('Text:', e.text);
    console.info('Trigger:', e.trigger);

    e.clearSelection();
});

clipboard.on('error', function(e) {
    console.error('Action:', e.action);
    console.error('Trigger:', e.trigger);
});

 

相关文章:

  • 2021-10-14
  • 2021-10-14
  • 2021-12-03
  • 2021-12-10
  • 2021-10-01
  • 2021-10-01
  • 2021-10-01
  • 2021-11-09
猜你喜欢
  • 2021-10-01
  • 2021-11-23
  • 2021-12-20
  • 2021-10-09
  • 2021-12-20
  • 2021-12-03
  • 2021-10-11
  • 2021-10-01
相关资源
相似解决方案