mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-19 16:57:22 +08:00
新增复制自定义指令
This commit is contained in:
28
admin/src/install/directives/copy.ts
Normal file
28
admin/src/install/directives/copy.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* perm 操作权限处理
|
||||
* 指令用法:
|
||||
* <el-button v-perms="['auth.menu/edit']">编辑</el-button>
|
||||
*/
|
||||
|
||||
import feedback from '@/utils/feedback'
|
||||
import useClipboard from 'vue-clipboard3'
|
||||
const clipboard = 'data-clipboard-text'
|
||||
export default {
|
||||
mounted: (el: HTMLElement, binding: any) => {
|
||||
el.setAttribute(clipboard, binding.value)
|
||||
const { toClipboard } = useClipboard()
|
||||
|
||||
el.onclick = () => {
|
||||
toClipboard(el.getAttribute(clipboard)!)
|
||||
.then(() => {
|
||||
feedback.msgSuccess('复制成功')
|
||||
})
|
||||
.catch(() => {
|
||||
feedback.msgError('复制失败')
|
||||
})
|
||||
}
|
||||
},
|
||||
updated: (el: HTMLElement, binding: any) => {
|
||||
el.setAttribute(clipboard, binding.value)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user