fix复制问题
This commit is contained in:
parent
6dbeaa9223
commit
52e0dc6303
@ -1,33 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
* v-clipboard 文字复制剪贴
|
* v-clipboard 文字复制剪贴
|
||||||
* Copyright (c) 2021 ruoyi
|
* Copyright (c) 2021 ruoyi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Clipboard from 'clipboard'
|
import Clipboard from 'clipboard'
|
||||||
export default {
|
export default {
|
||||||
bind(el, binding, vnode) {
|
mounted(el, binding, vnode) {
|
||||||
switch (binding.arg) {
|
switch (binding.arg) {
|
||||||
case 'success':
|
case 'success':
|
||||||
el._vClipBoard_success = binding.value;
|
el._vClipBoard_success = binding.value;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
el._vClipBoard_error = binding.value;
|
el._vClipBoard_error = binding.value;
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
const clipboard = new Clipboard(el, {
|
const clipboard = new Clipboard(el, {
|
||||||
text: () => binding.value,
|
text: () => binding.value,
|
||||||
action: () => binding.arg === 'cut' ? 'cut' : 'copy'
|
action: () => binding.arg === 'cut' ? 'cut' : 'copy'
|
||||||
});
|
});
|
||||||
clipboard.on('success', e => {
|
clipboard.on('success', e => {
|
||||||
const callback = el._vClipBoard_success;
|
const callback = el._vClipBoard_success;
|
||||||
callback && callback(e);
|
callback && callback(e);
|
||||||
});
|
});
|
||||||
clipboard.on('error', e => {
|
clipboard.on('error', e => {
|
||||||
const callback = el._vClipBoard_error;
|
console.log('复制失败', e)
|
||||||
callback && callback(e);
|
const callback = el._vClipBoard_error;
|
||||||
});
|
callback && callback(e);
|
||||||
el._vClipBoard = clipboard;
|
});
|
||||||
}
|
el._vClipBoard = clipboard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update(el, binding) {
|
update(el, binding) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user