File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" app-container" >
3
+ <el-tabs v-model =" activeName" >
4
+ <el-tab-pane label =" use clipboard directly" name =" directly" >
5
+ <el-input v-model =" inputData" placeholder =" 请输入内容" style =' width :400px ;' ></el-input >
6
+ <el-button type =" primary" icon =" document" @click =' handleCopy(inputData,$event)' >copy</el-button >
7
+ </el-tab-pane >
8
+ <el-tab-pane label =" use clipboard by v-directive" name =" v-directive" >
9
+ <el-input v-model =" inputData" placeholder =" 请输入内容" style =' width :400px ;' ></el-input >
10
+ <el-button type =" primary" icon =" document" v-clipboard:copy =' inputData' v-clipboard:success =' clipboardSuccess' >copy</el-button >
11
+ </el-tab-pane >
12
+ </el-tabs >
13
+ </div >
14
+ </template >
15
+
16
+ <script >
17
+ import clip from ' @/utils/clipboard' // use clipboard directly
18
+ import clipboard from ' @/directive/clipboard/index.js' // use clipboard by v-directive
19
+
20
+ export default {
21
+ directives: {
22
+ clipboard
23
+ },
24
+ data () {
25
+ return {
26
+ activeName: ' directly' ,
27
+ inputData: ' https://github.com/PanJiaChen/vue-element-admin'
28
+ }
29
+ },
30
+ methods: {
31
+ handleCopy (text , event ) {
32
+ clip (text, event )
33
+ },
34
+ clipboardSuccess () {
35
+ this .$message ({
36
+ message: ' 复制成功' ,
37
+ type: ' success' ,
38
+ duration: 1500
39
+ })
40
+ }
41
+ }
42
+ }
43
+ </script >
44
+
You can’t perform that action at this time.
0 commit comments