13.Vue + Element UI copy the contents of realized

1. Installation dependencies:

  npm  install vue-clipboard2  --save

 

2. main.js introduced

  Import View from 'view'
  import VueClipboard from 'sight-clipboard2'
  Vue.use (VueClipboard)

3. Use the page:

  <Model EL-V-INPUT = "address" : title = "address" > </ EL-INPUT> (: title declare a variable address in data)
  <A V-Clipboard: = Copy "address" V- clipboard: success = "onCopy" v -clipboard: error = "onError"> copy </a> (here: copy data corresponding to the variable to be copied with the content is the same)

The method in two 4.Methods:
  oncopy (E) {// successfully copied
    the this Message $. ({
      Message: 'copied successfully!',
      Type: 'Success'
    })
  },
  the onError (E) {// copy failure
    . the this Message $ ({
      Message: 'copy failed!',
      type: 'error'
    })
  },

 

Guess you like

Origin www.cnblogs.com/xintao/p/11024481.html