-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (54 loc) · 1.48 KB
/
index.js
File metadata and controls
55 lines (54 loc) · 1.48 KB
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
52
53
54
55
Vue.use(Toasted);
var main = new Vue({
el: '#input-text',
data: {
message: '',
status: false
},
computed: {
reversedMessage: function () {
var newMessage = '';
for (var codePoint of this.message) {
codePoint = codePoint.charCodeAt(0);
// A - Z 转换
if (codePoint >= 65 && codePoint <= 90) {
codePoint += 120315;
newMessage += String.fromCodePoint(codePoint);
}
// a - z 转换
else if (codePoint >= 97 && codePoint <= 122) {
codePoint += 120309;
newMessage += String.fromCodePoint(codePoint);
} else {
newMessage += String.fromCodePoint(codePoint);
}
}
return newMessage;
}
},
methods: {
update: function () {
if (this.message.length > 0) {
this.status = true;
} else {
this.status = false;
}
}
}
});
var clipboard = new ClipboardJS('.btn');
// 成功回调
clipboard.on('success', function (e) {
Vue.toasted.show('复制成功', {
position: 'bottom-center',
duration: 2000
});
e.clearSelection();
});
// 失败回调
clipboard.on('error', function (e) {
Vue.toasted.show('复制失败', {
position: 'bottom-center',
duration: 2000
});
});