Skip to content

Commit 4f2f136

Browse files
committed
add:add clipboard example
1 parent 8d53ae1 commit 4f2f136

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/views/clipboard/index.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
<template>
22
<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+

0 commit comments

Comments
 (0)