1

global.js

import Vue from 'vue'

// javascript import for when you're importing the css directly in your javascript
import "vue-navigation-bar/dist/vue-navigation-bar.css";

// import the library
import VueNavigationBar from "vue-navigation-bar";

Vue.component("vue-navigation-bar", VueNavigationBar);

nuxt.config.js

plugins: [
    { src: '~/plugins/global.js', ssr: false }
  ],

Error

window is not defined

I have tried all the possible solutions in nuxtjs documentation still getting same error. Thanks!

5
  • where do you call your importet library Commented Jun 18, 2020 at 6:55
  • In index.vue. Commented Jun 18, 2020 at 6:56
  • i mena how are you using it Commented Jun 18, 2020 at 6:59
  • ​<​template​>​   ​<​vue-navigation-bar​ :​options​=​"​navbarOptions​" /​>​ ​<​/​template​>​ Commented Jun 18, 2020 at 7:04
  • 1
    did you tried it to wrap in an <client-only></client-only>? Commented Jun 18, 2020 at 7:07

1 Answer 1

2

The solution is to wrap it in <client-only>

​<​template​>
   <client-only>
      <​vue-navigation-bar​ :​options​=​"​navbarOptions​" /​>
   </client-only>​​
<​/​template​>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.