https://github.com/egoist/v-copy
Vue directive to copy to clipboard. (1kB)
https://github.com/egoist/v-copy
clipboard copy directive vue
Last synced: 11 months ago
JSON representation
Vue directive to copy to clipboard. (1kB)
- Host: GitHub
- URL: https://github.com/egoist/v-copy
- Owner: egoist
- Created: 2017-10-23T06:40:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-25T14:34:26.000Z (over 4 years ago)
- Last Synced: 2025-08-11T00:55:02.706Z (11 months ago)
- Topics: clipboard, copy, directive, vue
- Language: JavaScript
- Homepage: https://v-copy.egoist.moe
- Size: 61.5 KB
- Stars: 85
- Watchers: 3
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# v-copy
Vue directive to copy to clipboard.
## Install
```bash
yarn add v-copy
```
CDN: [UNPKG](https://unpkg.com/v-copy/) | [jsDelivr](https://cdn.jsdelivr.net/npm/v-copy/) (It's automatically installed as global directive `v-copy` in CDN)
## Usage
First register the directive globally:
```js
import Copy from 'v-copy'
Vue.use(Copy)
```
Or locally:
```js
import { copy } from 'v-copy'
export default {
directives: {
copy
}
}
```
Then use it in template:
```vue
Copy!
```
**`v-copy:callback`**: executed after text is copied to clipboard.
```vue
Copy!
export default {
methods: {
handleCopied(text) {
alert(`Copied: ${text}`)
}
}
}
```
## Browser support
This supports what [copy-text-to-clipboard](https://github.com/sindresorhus/copy-text-to-clipboard) supports, namely ever-green browsers and IE9+. (Not all are carefully tested though :P)
## License
MIT © [EGOIST](https://github.com/egoist)