一个基于clipboard.js
的 React 复制组件
npm install --save react-clipboardjs-copy
属性 | 描述 | 类型 | 默认值 |
---|---|---|---|
action | 命令(cut 或 copy ),对应于 clipboard.js 属性 data-clipboard-action。 |
cut | copy |
copy |
target | React 组件将复制目标元素内容。 对应于clipboard.js 属性data-clipboard-target 。 |
string | function(elem: Element): Element | - |
text | React 组件将复制内容。 对应clipboard.js 属性data-clipboard-text |
string | function(elem: Element): string | |
container | 为了在任何其他改变焦点的库中使用,您需要将焦点元素设置为容器值。 | Element | body |
selection | 设置是否清除所选的副本或剪切 | boolean | false |
onSuccess | 操作成功回调 | function(event?: ClipboardJS.Event): void | - |
onError | 操作错误回调 | function(event?: ClipboardJS.Event): void | - |
git clone git@github.com:freeshineit/react-clipboardjs-copy.git
cd react-clipboardjs-copy
pnpm install
## development
pnpm run dev
## test
pnpm run test
## production
pnpm run build
MIT © Shine Shao