xe-command
v1.1.3
Published
Using JavaScript copy the text to the clipboard,Support IE、Chrome、Firefox、Opera、Safari、IOS、Android.
Downloads
27
Maintainers
Readme
xe-command
XECommand 使用原生js实现复制文本到剪贴板的函数,支持常用H5的浏览器IE、Chrome、Firefox、Opera、Safari、IOS、Android,压缩后还不到1KB的轻量级copy函数
Browser Support
| | | | | --- | --- | --- | --- | --- | --- | 10+ ✔ | Latest ✔ | Latest ✔ | 41+ ✔ | 29+ ✔ | 10+ ✔ |
Installing
npm install xe-command --save
import XECommand from 'xe-command'
<script src="https://cdn.jsdelivr.net/npm/xe-command/dist/xe-command.js"></script>
<script src="https://unpkg.com/xe-command/dist/xe-command.js"></script>
Example
import XECommand from 'xe-command'
document.querySelector('.button').addEventListener('click', evnt => {
if (XECommand.copy('Copy this content to the clipboard')) {
alery('Copy success.')
} else {
alert('The browser is not supported.')
}
})
License
Copyright (c) 2017-present, Xu Liangzhan