Skip to content
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 in Nuxt.js #112

Open
yeahliv opened this issue Jul 4, 2019 · 7 comments
Open

How to use it in Nuxt.js #112

yeahliv opened this issue Jul 4, 2019 · 7 comments

Comments

@yeahliv
Copy link

yeahliv commented Jul 4, 2019

ReferenceError
document is not defined

i think it because nuxt load dist/index.js , not load'dist/ssr.index.js

@yeahliv
Copy link
Author

yeahliv commented Jul 4, 2019

ok, it work, set ssr: false

plugins: [
    { src: '~/plugins/vue-js-toggle-button.js', ssr: false }
  ],

@cranx
Copy link

cranx commented Jul 15, 2019

But with ssr: false it means plugin doesn't support ssr, plugin should be updated and shouldn't refer to document when running on server side

@EdwinHoksberg
Copy link

What worked for me was including the generated ssr dist file instead of the default. I don't know how or why a separate file is generated but it works for me 🤷‍♂

For example in a nuxt plugin:
Before:

import Vue from 'vue';
import VueJsToggleButton from 'vue-js-toggle-button';

Vue.use(VueJsToggleButton);

After:

import Vue from 'vue';
import VueJsToggleButton from 'vue-js-toggle-button/dist/ssr.index';

Vue.use(VueJsToggleButton);

@DSoftwareArtist
Copy link

Not working when I run nuxt start

@antoinevulcain
Copy link

@EdwinHoksberg You saved my day! if you need anything from my API let me know!

@vesper8
Copy link

vesper8 commented Jun 25, 2020

@euvl @EdwinHoksberg's solution of loading vue-js-toggle-button/dist/ssr.index should be added to the SSR part of the readme, without it you have to disable SSR or you run into a document is not defined error

@hapetherw
Copy link

Not working when I run nuxt start

It's the same issue.
Is there any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants