A simple vuejs 2 binding for clipboard.js
npm install --save vue-clipboard2 or use
dist/vue-clipboard.min.js without webpack
For vue-cli user:
For standalone usage:
<!-- must place this line after vue.js -->
I want to copy texts without a specific button!
Yes, you can do it by using our new method:
where we replace the clipboard directives with a v-on directive.
Modern browsers have some limitations like that you can't use
window.open without a user interaction.
So there's the same restriction on copying things! Test it before you use it. Make sure you are not
using this method inside any async method.
It doesn't work with bootstrap modals
let container = this$refscontainerthis
Or you can let
container to current element by doing this:
VueClipboardconfigautoSetContainer = true // add this lineVue
You can use your Vue instance
vm.$el to get DOM elements via the usual traversal methods, e.g.:
This will allow you to access the rendered content of your components, rather than the components themselves.
PRs welcome, and issues as well! If you want any feature that we don't have currently, please fire an issue for a feature request.