# vue-clipboard3 **Repository Path**: fla126/vue-clipboard3 ## Basic Information - **Project Name**: vue-clipboard3 - **Description**: 改写vue-clipboard2,使之能用于vue3 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 3 - **Created**: 2020-11-06 - **Last Updated**: 2024-12-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vue-clipboard3 A simple vuejs 3 binding for clipboard.js ## Install `npm install --save https://gitee.com/fla126/vue-clipboard3.git` or use `dist/vue-clipboard.min.js` without webpack ## Usage For vue-cli user: ```javascript import VueClipboard from 'vue-clipboard3' import { createApp } from 'vue'; const app = createApp(); app.use(VueClipboard) ``` For standalone usage: ```html ``` ## I want to copy texts without a specific button! Yes, you can do it by using our new method: `this.$copyText`. See [sample2](https://github.com/Inndy/vue-clipboard2/blob/master/samples/sample2.html), 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 See [clipboardjs](https://clipboardjs.com/#advanced-usage) document ```js let container = this.$refs.container this.$copyText("Text to copy", container) ``` Or you can let `vue-clipboard3` set `container` to current element by doing this: ```js import { createApp } from 'vue'; import VueClipboard from 'vue-clipboard2' const app = createApp(); VueClipboard.config.autoSetContainer = true // add this line app.use(VueClipboard) ``` ## Sample ```html