12345678910111213141516171819202122 |
- import Clipboard from 'clipboard'
- export function handleClipboard (text, event, onSuccess, onError) {
- event = event || {}
- const clipboard = new Clipboard(event.target, {
- text: () => text
- })
- clipboard.on('success', () => {
- onSuccess()
- clipboard.off('error')
- clipboard.off('success')
- clipboard.destroy()
- })
- clipboard.on('error', () => {
- onError()
- clipboard.off('error')
- clipboard.off('success')
- clipboard.destroy()
- })
- clipboard.onClick(event)
- }
|