1. v-clipboard
Vue.js Clipboard Plugin
v-clipboard
Package: v-clipboard
Created by: euvl
Last modified: Fri, 16 Dec 2022 14:24:02 GMT
Version: 3.0.0-next.1
License: MIT
Downloads: 144,111
Repository: https://github.com/euvl/v-clipboard

Install

npm install v-clipboard
yarn add v-clipboard

npm
npm

Vue Clipboard

Demo

https://codesandbox.io/s/epic-waterfall-17yet5?file=/src/App.vue

Install

 npm install --save v-clipboard
 yarn add v-clipboard
 import Vue from 'vue'
import Clipboard from 'v-clipboard'

Vue.use(Clipboard)

Using

When an element that contains v-clipboard directive is clicked, the value of value will be copied into clipboard.


Copying static value (directive should receive actual value):

<button v-clipboard="value">
  Copy to clipboard
</button>
<button v-clipboard="'some text'">
  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)

Without plugin:

 import { Clipboard } from "v-clipboard"

Clipboard.copy(value)

Events

<button v-clipboard="foo"
        v-clipboard:success="clipboardSuccessHandler"
        v-clipboard:error="clipboardErrorHandler">
  Copy to clipboard
</button>
 {
  methods: {
    clipboardSuccessHandler ({ value, event }) {
      console.log('success', value)
    },

    clipboardErrorHandler ({ value, event }) {
      console.log('error', value)
    }
  }
}

Compatibility

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin