File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 2020 },
2121 "dependencies" : {
2222 "axios" : " >=0.18.1" ,
23+ "clipboard" : " ^2.0.4" ,
2324 "echarts" : " ^4.2.1" ,
2425 "element-ui" : " 2.7.2" ,
2526 "js-cookie" : " 2.2.0" ,
Original file line number Diff line number Diff line change 1+ <template >
2+ <div >
3+ <div slot =" content" @click =" copy" >>点击复制</div >
4+ <input type =" text" class =" tag-read" value =" " v-model =" input" >
5+ </div >
6+ </template >
7+
8+ <script type="text/ecmascript-6">
9+ import Clipboard from ' clipboard'
10+
11+ export default {
12+ name: ' Clipboard' ,
13+ data () {
14+ return {
15+ input: ' Hello'
16+ }
17+ },
18+ methods: {
19+ copy () {
20+ const clipboard = new Clipboard (' .tag-read' )
21+ clipboard .on (' success' , e => {
22+ console .log (' 复制成功' ) // 这里你如果引入了elementui的提示就可以用,没有就注释即可
23+ // 释放内存
24+ clipboard .destroy ()
25+ })
26+ clipboard .on (' error' , e => {
27+ // 不支持复制
28+ console .log (' 该浏览器不支持自动复制' )
29+ // 释放内存
30+ clipboard .destroy ()
31+ })
32+ }
33+ }
34+ }
35+ </script >
36+
37+ <style lang="stylus" rel="stylesheet/stylus">
38+
39+ </style >
You can’t perform that action at this time.
0 commit comments