How does the vue project implement the clipboard function--vue-clipboard2

  The vue project uses vue-clipboard2 to implement the function of the clipboard

  1. Install the vue-clipboard2 plugin: cnpm install --save vue-clipboard2

  2. Add main.js

import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

  3. Copy component: message binding text to be copied/onCopy copy success callback/onError copy failure callback

  v-clipboard:copy="message"

  v-clipboard:success="onCopy"

  v-clipboard:error="onError"

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775007&siteId=291194637
Recommended