vue-js-toggle-button icon indicating copy to clipboard operation
vue-js-toggle-button copied to clipboard

How to use it in Nuxt.js

Open yeahliv opened this issue 6 years ago • 7 comments

ReferenceError document is not defined

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

yeahliv avatar Jul 04 '19 08:07 yeahliv

ok, it work, set ssr: false

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

yeahliv avatar Jul 04 '19 08:07 yeahliv

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

cranx avatar Jul 15 '19 13:07 cranx

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);

EdwinHoksberg avatar Jul 31 '19 09:07 EdwinHoksberg

Not working when I run nuxt start

DSoftwareArtist avatar Sep 05 '19 03:09 DSoftwareArtist

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

antoinevulcain avatar May 06 '20 15:05 antoinevulcain

@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

vesper8 avatar Jun 25 '20 14:06 vesper8

Not working when I run nuxt start

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

leowtranx avatar Jun 15 '21 17:06 leowtranx