MeForma / vue-copy-to-clipboard

A simple vue 3 plugin to copy text to clipboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vue Copy To Clipboard

A simple vue 3 plugin to copy text to clipboard.

This plugin is compatible with browsers that can execute Clipboard API and browsers that can execute execCommand('copy'), alternatively.

Installation

# yarn
yarn add @meforma/vue-copy-to-clipboard

# npm
npm install @meforma/vue-copy-to-clipboard

Import

// In you main.js
// ... considering that your app creation is here
import copyText from "@meforma/vue-copy-to-clipboard";

createApp(App).use(copyText).mount("#app");

Usage

this.$copyText("Text to copy")
  .then(() => {
    console.log("copied!");
  })
  .catch(() => {
    console.log(`can't copy`);
  });

License

MIT License

About

A simple vue 3 plugin to copy text to clipboard

License:MIT License


Languages

Language:JavaScript 100.0%