New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use it nuxt js #8
Comments
@YannickSilva I've never used nuxt.js, but I will have a look! Maybe I find something |
Thanks man |
@YannickSilva I'm still working on it. I understand the problem. The thing is that with Nuxt you don't have I asked the question here. But I need some time to resolve it. |
I will wait for it bro, no problem |
@pmochine were you able to find a solution to this problem with nuxt js? |
@YannickSilva No :( |
No problem, i wil try do find anothr solution. Thanks for your time and effort |
Hey i found out a very useful post on medium about this problem. https://medium.com/@codebeast_/why-your-third-party-plugin-dont-work-in-nuxt-and-how-to-fix-it-d1a8caadf422 Take a look at it, it should help you |
@YannickSilva thanks. I have two issues. One is address by your medium article. The problem with I simply just don't know how I can build my bundles without using That's what I'm asking here https://stackoverflow.com/questions/61409902/vue-how-to-build-bundle-for-nuxt-with-vue-cli-service |
Have you tried to read the nuxt js docs ? |
Bro i tried right now the tips in this blog medium, and your plugin is working very well in nuxt js |
@YannickSilva what exactly did you do? :D |
Nuxt js first server side rendering your web site then it comes to client side, so your component only loads on client side. Whenever it tried to load on server side it fails because it mounted before i could detect any window, so i change it to render only on client side |
@YannickSilva I see. But it would be awesome if you could add some code. I'm sure other people want to see it as well 🙈 Thank you :) |
Yes i can, but i wanted to asked you something. Can you implement a lazy-loading funcionality in your component? I think it would be nice |
@YannickSilva I have to think about it. Because it makes the code much longer. And if people really need lazy-loading, they could just use a wrapper for it. Like this one https://github.com/heavyy/vue-intersect |
Hi guys, Ran into the same problem and found the solution. Anyway thanks for your work @pmochine this is a very cool plugin ! |
@pamartn Oh hi! Thanks for your comment :) Yeah that would be cool. But you could also just add it here as a comment and I would just add it later on. I don't know what you prefer more :) |
Create a new .js file in your plugins folder file e.g. Inside this file use the following:
Then at your
Now the component is globally available and can be used at any .vue file without issues. Hope this helps. |
@skoulix Thank you. I put this later on the readme page |
Followed this but I still get a "document is not defined" error for the component. Any suggestions as to why? This is my first Nuxt project so while I think I am understanding the cause issue, I do not know how to fix it. |
I'm using it with the same way and I don't have any issues. Do you have any other imports? Generally speaking when using Nuxt.js and window or document are undefined you need to call these at the client, both are not available at the server. You can wrap these when the client is there, an example:
|
It is my only import, just trying to have a video as a background in the default layout. If I add in the video-background component, hot-reload will update the page and show the video just fine. If I reload the page entirely however, that is when it crashes and gives me the document not defined error. With your last suggestion, I am confused as to where I should have that process.client check at. I read something similar with Nuxt.js documentation and had the code below in my component, but still didn't work.
|
Since you have declared this globally as a plugin at nuxt.config.js, you don't need to explicitly import it again. Having said that the correct syntax to require it at the client process is the following. Your code should look like this:
It depends with your code really. |
Thank you 😀! Managed to get it to work like this
|
Hi, just wondering how to use this plugin in Nuxt 3 ?
|
@iamdagy To be honest, I don't know. But I just googled your problem and these were the answers. Maybe it helps you: |
Thanks @pmochine with your help, the error is not showing in the console. But the video player is not rendering either.
|
Hi @pmochine @iamdagy @Ines2108, for NUXT 3 I used directive to make it work. Create plugins directory then add video-bg.client.ts (or any name but .client is obligatory for client side render, cause you don't have the window at ssr) file with
then you use the video-background tag |
@skoulix may I ask for your help? I was able to import the component in Nuxt 2 with your suggestion, but then I am getting the following error and cannot seem to get past it:
I am on nuxt 2.16.3 and vue 2.7.14 |
@lisaschumann Can you make sure that you are using the Vue2 version of this plugin and NOT the Vue3 version? |
@skoulix thanks so much! For some reason, after installing the package a second time I must have installed the latest rather than @1.3.1 |
Hey i'm trying to use it with nuxt js, but whenever i try it says document not found, can you help me with this
The text was updated successfully, but these errors were encountered: