vue-burger-menu
vue-burger-menu copied to clipboard
configure to use in nuxtjs
Hi, I am trying to get the plugin to work in my NuxtJS project. I found the steps needed for the code to only be run on client-side, but it doesn't seem to work for me. Can you see what I'm doing wrong?
nuxt.config.js:
plugins: [{ src: '~/plugins/vue-burger-menu.js', ssr: false }],
build: { vendor: ['vue-burger-menu'] }
plugins/vue-burger-menu.js:
import Vue from 'vue';
import VueBurgerMenu from 'vue-burger-menu';
if (!process.server) { (or if (process.client), also doesn't work)
Vue.use(VueBurgerMenu);
}
Slide.vue:
<script lang="ts">
import { Slide } from 'vue-burger-menu';
export default {
components: {
Slide
},
};
</script>
When using <Slide /> I get still the error that document is not defined so it still is run on the server-side.
Other strange behaviour: when calling a non-existing function in the plugins/vue-burger-menu.js file, I don't see an error for that anywhere (and the document is not defined error still there).
When changing the file path in nuxt.config.js that does give an error, so the config is pointed to the right file, but it looks like it just isn't run??
@Chris-Pratt-Clystnet check this https://github.com/mbj36/vue-burger-menu/issues/9