@ecip/ecip-web
Version:
A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features
33 lines (29 loc) • 618 B
JavaScript
import { Message } from 'element-ui'
import Clipboard from 'clipboard'
function clipboardSuccess() {
Message({
message: 'Copy successfully',
type: 'success',
duration: 1500
})
}
function clipboardError() {
Message({
message: 'Copy failed',
type: 'error'
})
}
export default function handleClipboard(text, event) {
const clipboard = new Clipboard(event.target, {
text: () => text
})
clipboard.on('success', () => {
clipboardSuccess()
clipboard.destroy()
})
clipboard.on('error', () => {
clipboardError()
clipboard.destroy()
})
clipboard.onClick(event)
}