Skip to content

Commit

Permalink
enable clipboard directive to support value updates
Browse files Browse the repository at this point in the history
  • Loading branch information
newraina committed Oct 7, 2023
1 parent b7f0e90 commit c124ab3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/vueClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ export default defineNuxtPlugin((nuxtApp) => {

nuxtApp.vueApp.directive('clipboard', {
beforeMount(el, { value, arg }) {
el.dataset._clipboard_value = value
useEventListener(el, 'click', () => {
switch (arg) {
case 'copy':
copy(value)
copy(el.dataset._clipboard_value)
break
}
})
},
updated(el, { value, arg }) {
switch (arg) {
case 'copy':
el.dataset._clipboard_value = value
break
}
},
})

return {
Expand Down

0 comments on commit c124ab3

Please sign in to comment.