test-copied
v1.0.5
Published
<!-- * @Author: your name * @Date: 2020-05-11 16:51:19 * @LastEditTime: 2020-05-12 09:51:35 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \test-copied\README.md -->
Downloads
7
Readme
test-copied
说明:文本复制
兼容性:支持Chrome42+, edge12+, IE9+, Firefox41+, Opera29+, Safari10+
main引入:
import clipboard from 'test-copied'
Vue.prototype.clipboard = clipboard
Example
<template>
<div id="app">
<button class="btn" :data-clipboard-text="testVal" @click="copyLink">
点我复制
</button>
</div>
</template>
<script>
export default {
name: 'App',
data () {
return {
testVal: '这是要复制的文本内容'
}
},
methods: {
copyLink () {
let clipboard = new this.clipboard(".btn")
clipboard.on('success', function () {
alert('复制成功')
})
clipboard.on('error', function () {
alert('复制失败')
})
}
}
}
</script>