我正在尝试使用ClipboardJS库将当前页面URL复制到剪贴板。我尽力了,并在这里提出问题。
以下是代码:
的Javascript / Jquery的:
graph G {
0 [label=""];
1 [label=""];
2 [label=""];
3 [label=""];
4 [label=""];
5 [label=""];
6 [label=""];
7 [label=""];
8 [label=""];
9 [label="", shape="none"];
10 [label="", shape="none"];
11 [label="", shape="none"];
12 [label="", shape="none"];
13 [label="", shape="none"];
14 [label="", shape="none"];
15 [label="", shape="none"];
16 [label="", shape="none"];
17 [label="", shape="none"];
18 [label="", shape="none"];
19 [label="", shape="none"];
20 [label="", shape="none"];
0 -- 1;
0 -- 2;
0 -- 3;
0 -- 4;
1 -- 5;
2 -- 5;
2 -- 6;
3 -- 6;
3 -- 7;
4 -- 7;
4 -- 8;
1 -- 8;
1 -- 9;
2 -- 10;
3 -- 11;
4 -- 12;
5 -- 13;
6 -- 14;
7 -- 15;
8 -- 16;
5 -- 17;
6 -- 18;
7 -- 19;
8 -- 20;
}
HTML:
new Clipboard('.copy', {
text: function(trigger) {
return window.location.href;
}
});
这是Code Pen:
答案 0 :(得分:0)
我通过
解决了这个问题$.fn.modal.Constructor.prototype.enforceFocus = function() {
new Clipboard('.copy', {
text: function(trigger) {
return window.location.href;
}
});
};
看起来像bootstrap在剪贴板库中存在一些问题。感谢https://github.com/zenorocha/clipboard.js/issues/155#issuecomment-217372642