2.3.0 • Published 4 years ago
@qualitech/v-clipboard v2.3.0
Vue.js Clipboard
Install
npm install --save v-clipboardimport Vue from 'vue'
import Clipboard from 'v-clipboard'
Vue.use(Clipboard)Using
When an element that contains
v-clipboarddirective is clicked, the value ofvaluewill be copied into clipboard.
Copying static value (directive should receive actual value):
<button v-clipboard="value">
Copy to clipboard
</button>Copying dynamic value (directive should recieve a function that returns value):
<button v-clipboard="() => value">
Copy to clipboard
</button>Copying anything in your methods:
this.$clipboard(value)Events
<button v-clipboard="foo"
v-clipboard:success="clipboardSuccessHandler" // Success event handler
v-clipboard:error="clipboardErrorHandler"> // Error event handler
Copy to clipboard
</button>{
methods: {
clipboardSuccessHandler ({ value, event }) {
console.log('success', value)
},
clipboardErrorHandler ({ value, event }) {
console.log('error', value)
}
}
}Compatibility
2.3.0
4 years ago