1..安装依赖
npm install clipboard --save
2.在项目中使用
import ClipboardJS from 'clipboard'
//放在要处理的method方法中
this.$nextTick(() => {
this.detailerList.map((v, index) => {
const dom = this.$refs[`copy2${index}`][0].$el
const clipboard = new ClipboardJS(dom, {
text: function() {
return v.address
}
})
clipboard.on('success', e => {
this.$Message.success('复制成功!')
})
})
})