1 | # v-copy
|
2 |
|
3 | Vue directive to copy to clipboard.
|
4 |
|
5 | ## Install
|
6 |
|
7 | ```bash
|
8 | yarn add v-copy
|
9 | ```
|
10 |
|
11 | 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)
|
12 |
|
13 | ## Usage
|
14 |
|
15 | First register the directive globally:
|
16 |
|
17 | ```vue
|
18 | import Copy from 'v-copy'
|
19 |
|
20 | Vue.use(Copy)
|
21 | ```
|
22 |
|
23 | Or locally:
|
24 |
|
25 | ```js
|
26 | import { copy } from 'v-copy'
|
27 |
|
28 | export default {
|
29 | directives: {
|
30 | copy
|
31 | }
|
32 | }
|
33 | ```
|
34 |
|
35 | Then use it in template:
|
36 |
|
37 | ```vue
|
38 | <template>
|
39 | <button v-copy="`some text`">Copy!</button>
|
40 | </template>
|
41 | ```
|
42 |
|
43 | ## Browser support
|
44 |
|
45 | 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)
|
46 |
|
47 | ## License
|
48 |
|
49 | MIT © [EGOIST](https://github.com/egoist)
|