Rap 原分销系统代码Web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5698fca51f100f3ce499ec5f8bf38006c25e69ee.svn-base 745B

5 months ago
123456789101112131415161718192021222324252627282930313233343536
  1. import Vue from 'vue'
  2. import Clipboard from 'clipboard'
  3. function clipboardSuccess() {
  4. Vue.prototype.$message({
  5. message: 'Copy successfully',
  6. type: 'success',
  7. duration: 1500
  8. })
  9. }
  10. function clipboardError() {
  11. Vue.prototype.$message({
  12. message: 'Copy failed',
  13. type: 'error'
  14. })
  15. }
  16. export default function handleClipboard(text, event) {
  17. const clipboard = new Clipboard(event.target, {
  18. text: () => text
  19. })
  20. clipboard.on('success', () => {
  21. clipboardSuccess()
  22. clipboard.off('error')
  23. clipboard.off('success')
  24. clipboard.destroy()
  25. })
  26. clipboard.on('error', () => {
  27. clipboardError()
  28. clipboard.off('error')
  29. clipboard.off('success')
  30. clipboard.destroy()
  31. })
  32. clipboard.onClick(event)
  33. }