File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,20 @@ import Message from 'vue-m-message'
14
14
export interface CopyElement extends HTMLElement {
15
15
copyValue : string
16
16
}
17
-
17
+ /**
18
+ * eg.
19
+ * 1、 v-copy="'copyContent'" // 默认是dblclick,localhost及https复制才会生效
20
+ * 2、 v-copy:dblclick.legacy="'copyContent'" // 兼容模式,所有浏览器都生效
21
+ */
18
22
export const copy = {
19
23
mounted ( el : CopyElement , binding : DirectiveBinding < string > ) {
20
- const { isSupported, copy } = useClipboard ( )
21
- if ( ! isSupported . value ) {
24
+ const legacy = binding . modifiers ?. legacy === true
25
+ const { isSupported } = useClipboard ( )
26
+ const { copy } = useClipboard ( { legacy } )
27
+ if ( ! isSupported . value && ! legacy ) {
22
28
throw new Error ( '[Directive: copy]: Your browser does not support Clipboard API' )
23
29
}
30
+
24
31
const { value } = binding
25
32
if ( value ) {
26
33
el . copyValue = value
You can’t perform that action at this time.
0 commit comments