Blame view
src/views/clipboard/index.vue
1.38 KB
d7d9c38c2 auto commit the c... |
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 |
<template> <div class="app-container"> <el-tabs v-model="activeName"> <el-tab-pane label="use clipboard directly" name="directly"> <el-input v-model="inputData" placeholder="Please input" style="width:400px;max-width:100%;" /> <el-button type="primary" icon="el-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="Please input" style="width:400px;max-width:100%;" /> <el-button v-clipboard:copy="inputData" v-clipboard:success="clipboardSuccess" type="primary" icon="el-icon-document"> 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 { name: 'ClipboardDemo', 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: 'Copy successfully', type: 'success', duration: 1500 }) } } } </script> |