I added plugin: vue-burger-menu to my nuxt.js project. And i have an error: "document is not defined". I know, that this plugin is available only for client-side. So I found in vue documentation enter link description here what I have to do to fix it. It works only for first refresh. Then I have again document is not defined.
nuxt.config.js:
build: {
vendor: ['vue-burger-menu'],
}
plugins: [
{ src: '~/plugins/vue-burger-menu.js', ssr: false }
],
Add a file to my plugins folder called "vue-burger-menu.js":
import Vue from 'vue';
import VueBurgerMenu from 'vue-burger-menu';
if (process.browser) {
Vue.use(VueBurgerMenu);
}
nav template
<template lang="pug">
Slide(right)
nav.menu_vertical
</template>
<script>
import { Slide } from 'vue-burger-menu'
export default {
name: 'Nav',
components: {
Slide
},
}

Replace deprecated process.browser with process.client
if (process.client) {
Vue.use(VueBurgerMenu);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With