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

Not compatible with Vue 3 RC

Open ahmedh01 opened this issue 3 years ago • 8 comments

Running into the following issue trying to use vue-youtube on Vue 3 RC

Installed vue-youtube via npm, and imported it into my project globally in main.js following the directions given by the Vue 3 docs.

main.js

import { createApp } from 'vue'
import App from './App.vue'
import VueYoutube from 'vue-youtube'

createApp(App)
  .use(VueYoutube)
  .mount('#app')

In the console, I get the following error:

Uncaught TypeError: Cannot set property '$youtube' of undefined

Might be something minor?

ahmedh01 avatar Sep 15 '20 03:09 ahmedh01

same here

jameshwc avatar Nov 11 '20 01:11 jameshwc

I think migrating this to Vue3 is pretty easy:

  • beforeDestroy -> beforeUnmount
  • Use render() { return Vue.h('div'); } instead of render(h) { return h('div'); }
  • Maybe something minor in the library setup

sampullman avatar Dec 30 '20 07:12 sampullman

I will migrate to version 3 soon.

anteriovieira avatar Feb 03 '21 12:02 anteriovieira

Any ETA for migrating to vue 3 ?

olemarius avatar Feb 16 '21 16:02 olemarius

Also looking forward to getting Vue 3 support. Did anyone found a workaround in the meantime?

ggraca avatar Jun 01 '21 12:06 ggraca

I just injected the api js as a workaround.

  setup(props, context) {    
    var tag = document.createElement('script')    
    tag.src = 'http://www.youtube.com/iframe_api'
    const firstScriptTag = document.getElementsByTagName('script')[0]    
    firstScriptTag.parentNode?.insertBefore(tag, firstScriptTag)
}

Then you can assign player= new YT.player and use its api. details at my repo: https://github.com/jameshwc/Million-Singer-Vue-Frontend/blob/main/src/views/Song.vue

jameshwc avatar Jun 03 '21 01:06 jameshwc

I created a PR with the changes necessary to get it working with Vue3: https://github.com/anteriovieira/vue-youtube/pull/82

I did not have time to fully dive into to the rollup setup, so ignore the changes i made in the PR to the /dist folder, i made those only to get the component working for my own project.

ainarend avatar Jul 19 '21 13:07 ainarend

Published a lightweight component that works with both Vue 2/3

https://github.com/wobsoriano/vue-lite-youtube-embed

wobsoriano avatar Aug 27 '21 06:08 wobsoriano