Skip to content

Commit ac84961

Browse files
committed
fix: 修复copyupdate时的错误
1 parent b0e93bf commit ac84961

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/plugins/directives.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { ElMessage } from 'element-plus';
77
export default function (app: any): void {
88
app.directive('copy', {
99
/* ... */
10+
updated(el: HTMLElement, binding: any): void {
11+
el.setAttribute('data-clipboard-text', binding.value);
12+
},
1013
mounted(el: HTMLElement, binding: any): void {
1114
el.setAttribute('data-clipboard-text', binding.value);
1215
let clipboard: any;
@@ -31,7 +34,7 @@ export default function (app: any): void {
3134
//解决clipboard第一次点击不生效问题,那就在enter时实例化Clipboard
3235
el.addEventListener('mouseenter', () => {
3336
clipboard = new Clipboard(el, {
34-
text: () => binding.value,
37+
text: () => el.getAttribute('data-clipboard-text'),
3538
});
3639
});
3740
},

0 commit comments

Comments
 (0)