feross/clipboard-copy
关于
适用于 Web 的轻量级剪贴板复制工具
效率与自动化实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文clipboard-copy

Lightweight copy to clipboard for the web
The goal of this package is to offer simple copy-to-clipboard functionality in modern web browsers using the fewest bytes. To do so, this package only supports modern browsers. No fallback using Adobe Flash, no hacks. Just 30 lines of code.
Unlike other implementations, text copied with clipboard-copy is clean and
unstyled. Copied text will not inherit HTML/CSS styling like the page's background
color.
Supported browsers: Chrome, Firefox, Edge, Safari.
Works in the browser with browserify!
install
npm install clipboard-copy
usage
const copy = require('clipboard-copy')
button.addEventListener('click', function () {
copy('This is some cool text')
})
API
successPromise = copy(text)
Copy the given text to the user's clipboard. Returns successPromise, a promise that resolves if the copy was successful and rejects if the copy failed.
Note: in most browsers, copying to the clipboard is only allowed if copy() is
triggered in direct response to a user gesture like a 'click' or a 'keypress'.
comparison to alternatives
clipboard-copy(this package): 508 B gzippedclipboard-js: 1.7 kB gzippedclipboard: 3.2 kB gzipped
testing
Testing this module is currently a manual process. Open test.html in your web browser and follow the short instructions. The web page will always load the latest version of the module, no bundling is necessary.
license
MIT. Copyright (c) Feross Aboukhadijeh.
探索相关项目
加载中…