1. xe-clipboard
纯 Javascript 实现复制文本到剪贴板,支持IE、Chrome、Firefox、Opera、Safari、IOS、Android
xe-clipboard
Package: xe-clipboard
Created by: x-extends
Last modified: Tue, 24 May 2022 22:08:50 GMT
Version: 1.10.2
License: MIT
Downloads: 1,002
Repository: https://github.com/x-extends/xe-clipboard

Install

npm install xe-clipboard
yarn add xe-clipboard

xe-clipboard

gitee star
npm version
npm downloads
gzip size: JS
npm license

基于 execCommand API 实现复制内容到剪贴板,支持主流的 H5 浏览器 IE, Chrome, Firefox, Opera, Safari, IOS, Android
压缩大小 < 0.5KB

Browser Support

IE Edge Chrome Firefox Opera Safari
10+ ✔ Latest ✔ 42+ ✔ 41+ ✔ 29+ ✔ 10+ ✔

Installing

 npm install xe-clipboard
 <script src="https://cdn.jsdelivr.net/npm/xe-clipboard"></script>

Example

Run Test

 <button id="btn1">Copy</button>
 document.getElementById('btn1').addEventListener('click', function (evnt) {
  // 由于浏览器的安全机制,操作剪贴板必须在事件之内才能有效
  if (XEClipboard.copy('Copy this content to the clipboard.')) {
    alert('Copy success.')
  } else {
    alert('The browser is not supported.')
  }
})

License

MIT © 2017-present, Xu Liangzhan

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin