Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Window is not defined #8

Open
jewe11er opened this issue Mar 18, 2020 · 4 comments
Open

Window is not defined #8

jewe11er opened this issue Mar 18, 2020 · 4 comments

Comments

@jewe11er
Copy link

Get a error on Nuxt in node_modules/v-markdown-editor/dist/v-markdown-editor.js:10:
Error:
window is not defined

@vjdv
Copy link

vjdv commented Apr 12, 2020

i'm having same problem :/

@vjdv
Copy link

vjdv commented Apr 12, 2020

I made it work this way:

Wrapped with client-only in view:

<client-only>
  <markdown-editor />
<client-only>

Set mode=client in nuxt config:

{ src: '~/plugins/markdown-editor.js', mode: 'client' }

hope it helps!

@and-jan
Copy link

and-jan commented Apr 17, 2020

@vjdv Thanks for the hint! I am also using nuxt but now I get the error
[Vue warn]: Failed to mount component: template or render function not defined..
Do you have any idea how to solve this?

Edit: I accidentally used Vue.component('markdown-editor', Editor) instead of Vue.use(Editor), now it's working fine!
Also it's also possible to use
{ src: '~/plugins/vMarkdownEditor.js', ssr: false }
in nuxt.config.js, so you don't have to use the <client-only> wrapper.

@igorjacauna
Copy link

Usually, I use my plugin filename as markdow-editor.client.js. So, automatically Nuxt knows that the plugin must be loaded only in client side. This happen because of *.client.js

// nuxt.config.js
export default {
    plugins: [
        '@/plugins/markdow-editor.client'
    ]
}

That's enougth to solve problems like Window is not defined, since the plugin only will work on client side

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

No branches or pull requests

4 participants