All Projects → Inndy → Vue Clipboard2

Inndy / Vue Clipboard2

Licence: mit
A simple vue2 binding to clipboard.js

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to Vue Clipboard2

Vee Validate
✅ Form Validation for Vue.js
Stars: ✭ 8,820 (+445.45%)
Mutual labels:  vuejs2, vue2
Aspnetcore Vue Starter
*NEW* Asp.net Core & Vue.js (ES6) SPA Starter kit - Vuex, webpack, Web API, Docker, and more! By @TrilonIO
Stars: ✭ 1,182 (-26.9%)
Mutual labels:  vuejs2, vue2
Electron Vue Webpack
A minimal Electron + Vue 2 + Webpack 2 setup for quick development.
Stars: ✭ 70 (-95.67%)
Mutual labels:  vuejs2, vue2
Vue Cnode
基于vue2 + vue-router + vuet + ES6 + less + flex.css重写vue版cnode社区,使用webpack2打包
Stars: ✭ 1,134 (-29.87%)
Mutual labels:  vuejs2, vue2
Vuex Simple Structure
📈 A repository showcasing a simple Vuex store inside a Vue.js application based on Large-scale Vuex application structures @3yourmind
Stars: ✭ 87 (-94.62%)
Mutual labels:  vuejs2, vue2
Laravel Vue Tasks
📝 Task app built with Laravel 5.5 and Vue 2
Stars: ✭ 66 (-95.92%)
Mutual labels:  vuejs2, vue2
Docker Nuxt
Docker image to run NUXT.js application in production mode
Stars: ✭ 71 (-95.61%)
Mutual labels:  vuejs2, vue2
Mdi Vue
Material design icons for vue.js
Stars: ✭ 53 (-96.72%)
Mutual labels:  vuejs2, vue2
Copy Paths To Clipboard
Copy paths in a variety of formats to the clipboard with Alfred
Stars: ✭ 83 (-94.87%)
Mutual labels:  copy, clipboard
Express Vue
Vue rendering engine for Express.js. Use .Vue files as templates using streams
Stars: ✭ 1,226 (-24.18%)
Mutual labels:  vuejs2, vue2
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (-96.23%)
Mutual labels:  vuejs2, vue2
Quasar Starter Kit
Quasar CLI Starter Kit
Stars: ✭ 92 (-94.31%)
Mutual labels:  vuejs2, vue2
Vue Vscode Snippets
These snippets were built to supercharge my workflow in the most seamless manner possible.
Stars: ✭ 1,083 (-33.02%)
Mutual labels:  vuejs2, vue2
Muse Ui
Material Design UI library for Vuejs 2.0
Stars: ✭ 8,302 (+413.42%)
Mutual labels:  vuejs2, vue2
Vuex Flash
VueJs Flash Message Component within Vuex
Stars: ✭ 54 (-96.66%)
Mutual labels:  vuejs2, vue2
Vue Builder Webpack Plugin
Webpack plugin to build vue files automatically
Stars: ✭ 70 (-95.67%)
Mutual labels:  vuejs2, vue2
Vue Prism
Simple Vue.js Syntax highlighting with Prism.js
Stars: ✭ 43 (-97.34%)
Mutual labels:  vuejs2, vue2
Vue Image Loader
Vue progressive image loader plugin like Medium
Stars: ✭ 47 (-97.09%)
Mutual labels:  vuejs2, vue2
Vue Particles
Vue.js component for particles backgrounds ✨
Stars: ✭ 1,220 (-24.55%)
Mutual labels:  vuejs2, vue2
Xcui
🍴 A Vue.js 2.x desktop components colletion
Stars: ✭ 88 (-94.56%)
Mutual labels:  vuejs2, vue2

vue-clipboard2

A simple vuejs 2 binding for clipboard.js

Install

npm install --save vue-clipboard2 or use dist/vue-clipboard.min.js without webpack

Usage

For vue-cli user:

import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'

Vue.use(VueClipboard)

For standalone usage:

<script src="vue.min.js"></script>
<!-- must place this line after vue.js -->
<script src="dist/vue-clipboard.min.js"></script>

I want to copy texts without a specific button!

Yes, you can do it by using our new method: this.$copyText. See sample2, 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.

Before using this feature, read: this issue and this page first.

It doesn't work with bootstrap modals

See clipboardjs document and this pull request, container option is available like this:

let container = this.$refs.container
this.$copyText("Text to copy", container)

Or you can let vue-clipboard2 set container to current element by doing this:

import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'

VueClipboard.config.autoSetContainer = true // add this line
Vue.use(VueClipboard)

Sample

<div id="app"></div>

<template id="t">
  <div class="container">
    <input type="text" v-model="message">
    <button type="button"
      v-clipboard:copy="message"
      v-clipboard:success="onCopy"
      v-clipboard:error="onError">Copy!</button>
  </div>
</template>

<script>
new Vue({
  el: '#app',
  template: '#t',
  data: function () {
    return {
      message: 'Copy These Text'
    }
  },
  methods: {
    onCopy: function (e) {
      alert('You just copied: ' + e.text)
    },
    onError: function (e) {
      alert('Failed to copy texts')
    }
  }
})
</script>

Sample 2

<div id="app"></div>

  <template id="t">
    <div class="container">
    <input type="text" v-model="message">
    <button type="button" @click="doCopy">Copy!</button>
    </div>
  </template>

  <script>
  new Vue({
    el: '#app',
    template: '#t',
    data: function () {
      return {
        message: 'Copy These Text'
      }
    },
    methods: {
      doCopy: function () {
        this.$copyText(this.message).then(function (e) {
          alert('Copied')
          console.log(e)
        }, function (e) {
          alert('Can not copy')
          console.log(e)
        })
      }
    }
  })
  </script>

You can use your Vue instance vm.$el to get DOM elements via the usual traversal methods, e.g.:

this.$el.children[1].children[2].textContent

This will allow you to access the rendered content of your components, rather than the components themselves.

Contribution

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.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].