Skip to content

Vue.js clipboard library (no dependencies, less than 2kb)

License

Notifications You must be signed in to change notification settings

chenyuan8059/v-clipboard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

Vue.js Clipboard

Install

npm install --save 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>

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

About

Vue.js clipboard library (no dependencies, less than 2kb)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%