An open API service indexing awesome lists of open source software.

https://github.com/cinob/vue-reactive-clipboard

A minisize vue2/3 reactive clipboard
https://github.com/cinob/vue-reactive-clipboard

clipboard copy vue vue2 vue3

Last synced: about 1 month ago
JSON representation

A minisize vue2/3 reactive clipboard

Awesome Lists containing this project

README

          

# vue-reactive-clipboard

A minisize vue2/3 reactive clipboard

## Install

Install with [yarn](https://yarnpkg.com):

```bash
$ yarn add vue-reactive-clipboard
```

Install with [npm](https://npmjs.com):

```bash
$ npm i vue-reactive-clipboard --save
```

## Usage

### `Vue3`

```html

{{ content }}

import { ref, watchEffect } from 'vue'
import { useClipboard } from 'vue-reactive-clipboard'
const { text, copy } = useClipboard()

const content = ref('click me to copy!')
watchEffect(() => {
if (text.value) {
console.log('copy successed: ' + text.value)
}
})

```
### `Vue2`
Install [`@vue/composition-api`](https://github.com/vuejs/composition-api) as a dependency.
```html


{{ content }}


import { ref, watchEffect, defineComponent } from '@vue/composition-api'
import { useClipboard } from 'vue-reactive-clipboard'
export default defineComponent({
setup () {
const { text, copy } = useClipboard()
const content = ref('click me to copy!')
watchEffect(() => {
if (text.value) {
console.log('copy successed: ' + text.value)
}
})
return {
content,
copy
}
}
})

```