forked from AkkomaGang/admin-fe
add:add clipboard example
This commit is contained in:
parent
8d53ae1259
commit
4f2f136dd0
1 changed files with 42 additions and 0 deletions
|
@ -1,2 +1,44 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
<el-tabs v-model="activeName">
|
||||||
|
<el-tab-pane label="use clipboard directly" name="directly">
|
||||||
|
<el-input v-model="inputData" placeholder="请输入内容" style='width:400px;'></el-input>
|
||||||
|
<el-button type="primary" icon="document" @click='handleCopy(inputData,$event)'>copy</el-button>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="use clipboard by v-directive" name="v-directive">
|
||||||
|
<el-input v-model="inputData" placeholder="请输入内容" style='width:400px;'></el-input>
|
||||||
|
<el-button type="primary" icon="document" v-clipboard:copy='inputData' v-clipboard:success='clipboardSuccess'>copy</el-button>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import clip from '@/utils/clipboard' // use clipboard directly
|
||||||
|
import clipboard from '@/directive/clipboard/index.js' // use clipboard by v-directive
|
||||||
|
|
||||||
|
export default {
|
||||||
|
directives: {
|
||||||
|
clipboard
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
activeName: 'directly',
|
||||||
|
inputData: 'https://github.com/PanJiaChen/vue-element-admin'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleCopy(text, event) {
|
||||||
|
clip(text, event)
|
||||||
|
},
|
||||||
|
clipboardSuccess() {
|
||||||
|
this.$message({
|
||||||
|
message: '复制成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue