copyActiveCode(e, text) {
const clipboard = new Clipboard(e.target, { text: () = text })
clipboard.on('success', e = {
this.$message({ type: 'success', message: '拷贝取得成功' })
// 释放出来运行内存
clipboard.off('error')
clipboard.off('success')
clipboard.destroy()
clipboard.on('error', e = {
// 不兼容拷贝
this.$message({ type: 'waning', message: '该访问器不兼容全自动拷贝' })
// 释放出来运行内存
clipboard.off('error')
clipboard.off('success')
clipboard.destroy()
clipboard.onClick(e)
应用方式二 template span {{ code }} /span id="tag-copy" -- 做为挑选器的标志应用用class也行 -- :data-clipboard-text="code" -- 这儿放要拷贝的內容 -- title="点一下拷贝" @click="copyActiveCode($event,code)"/ /template // methods copyActiveCode() { const clipboard = new Clipboard("#tag-copy") clipboard.on('success', e = { this.$message({ type: 'success', message: '拷贝取得成功' }) // 释放出来运行内存 clipboard.destroy() clipboard.on('error', e = { // 不兼容拷贝 this.$message({ type: 'waning', message: '该访问器不兼容全自动拷贝' }) // 释放出来运行内存 clipboard.destroy() 之上便是文中的所有內容,期待对大伙儿的学习培训有一定的协助,也期待大伙儿多多的适用诺心互联网。 (责任编辑:admin) |