-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipoard.js.async.html
51 lines (46 loc) · 1.2 KB
/
clipoard.js.async.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ClipoardJS Async</title>
<style type="text/css">
.copy,
.btn {
margin: 0 auto;
width: 200px;
height: 30px;
line-height: 30px;
border: none;
box-shadow: none;
}
</style>
</head>
<body>
<h3>ClipoardJS 同步复制</h3>
<button type="submit" class="copy">复制</button>
<!-- <button type="submit" class="btn">copy</button> -->
</body>
<script src="./assets/javascript/clipboard.min.js"></script>
<script>
let copy = document.querySelector('.copy');
copy.addEventListener('click', function () {
handleCopy(`测试-${Math.random()}`);
})
function handleCopy(text) {
var clipboard = new ClipboardJS('.copy', {
text: function (trigger) {
return text;
}
});
clipboard.on('success', function (e) {
e.clearSelection();
clipboard.destroy();
console.log('口令复制成功,打开手淘特价版领取!')
});
clipboard.on('error', function (e) {
console.log('口令复制失败!')
});
}
</script>
</html>