copy

Vue directive to add a click-to-copy.

Installation

Global install:

import Vue from 'vue';
import { copy } from 'vuetensils/src/directives';

Vue.directive('copy', copy);

Local install:

<script>
  import { copy } from 'vuetensils/src/directives';

  export default {
    directives: {
      copy,
    },
  };
</script>

Usage

<template>
  <div>
    <p>Click this button then paste somewhere</p>
    <button v-copy="'Clipboard says what?'">
      Click to copy
    </button>
  </div>
</template>

Note that you must pass a string inside the v-copy value.