vue-clipboard2 icon indicating copy to clipboard operation
vue-clipboard2 copied to clipboard

Vue 3 Support

Open brendan1212 opened this issue 4 years ago • 12 comments

Hi! I just want to throw in my vote for Vue 3 support, since its now in RC5, which means we're getting very close and the API shouldn't have any more breaking changes. Thanks!

brendan1212 avatar Aug 01 '20 22:08 brendan1212

+1

jd-solanki avatar Sep 17 '20 10:09 jd-solanki

I would like to know if the author plans to support Vue3 too.

gterras avatar Sep 19 '20 15:09 gterras

I urgently needed this for one of our projects, so I came up with a port for Vue 3: https://github.com/soerenmartius/vue3-clipboard

soerenmartius avatar Oct 02 '20 10:10 soerenmartius

Hi @soerenmartius It's really great. Can we have function like $copyText??

jd-solanki avatar Oct 02 '20 10:10 jd-solanki

Hi @soerenmartius It's really great. Can we have function like $copyText??

Thanks! Yeah sure. That's just an unstable pre v0.1.0 release. I am working on converting everything to Typescript. Will release a stable version later this weekend that will also allow for standalone usage without loading the whole thing globally. I will come back to you later this weekend.

soerenmartius avatar Oct 02 '20 16:10 soerenmartius

Hi @soerenmartius It's really great. Can we have function like $copyText??

Just added it :)

soerenmartius avatar Oct 03 '20 16:10 soerenmartius

I also wanted a Vue 3 version of this for use just with the composition API in the setup() function. No Vue plugin, no adding to this, no Vue directive, just a simple method. So I made https://www.npmjs.com/package/vue-clipboard3. Feel free to use! Issues/PRs/contributions welcome 📋

JamieCurnow avatar Dec 16 '20 13:12 JamieCurnow

Can you support Vue 3? Thank you.

snowdream avatar May 04 '21 03:05 snowdream

@Inndy I saw PR #121 was merged. Can this issue be closed?

zenflow avatar May 16 '22 17:05 zenflow

@Inndy I tried it out and this package does indeed seem to be compatible with Vue 3

I suggest closing this issue, and to remove confusion, also change the description in the README:

https://github.com/Inndy/vue-clipboard2/blob/be0e6df47b46b8cb834991a3188a2b604a06b4fa/README.md?plain=1#L3

to match the description in package.json:

https://github.com/Inndy/vue-clipboard2/blob/be0e6df47b46b8cb834991a3188a2b604a06b4fa/package.json#L4

zenflow avatar May 16 '22 18:05 zenflow

Use this https://vueuse.org/core/useClipboard/

jd-solanki avatar May 17 '22 05:05 jd-solanki

@zenflow the plugin works, the directive doesn't. Some directive lifecycle hooks name changed so there's a mapping required based on current vue version. @Inndy if you want can make a PR.

Example from @vueuse

https://v3-migration.vuejs.org/breaking-changes/custom-directives.html#_3-x-syntax

bind → beforeMount
inserted → mounted
update # removed use updated
componentUpdated → updated
unbind → unmounted

https://github.com/Inndy/vue-clipboard2/blob/be0e6df47b46b8cb834991a3188a2b604a06b4fa/vue-clipboard.js#L35-L78

renatodeleao avatar Jul 05 '22 16:07 renatodeleao