sudhakar selva
sudhakar selva

Reputation: 397

How to solve document not defined error when using nuxtJS + Vue2-Editor?

I am trying to setup nuxtjs app with vue2-editor.if I try navigating to editor page via client navigation its loading but if i visit or refresh(eg.com/editor) page directly .i am getting document not defined error.

I have identified it because vue2 editor does not support ssr but i have disable it in nuxt-config.js for only client side.but error not going away.please share what i am doing wrong?

//plugin.quill-editor.js

import Vue from 'vue'

if (process.client) {
    const VueEditor = require('vue2-editor') //tried normal import as wel
    Vue.use(VueEditor)
}

//nuxt.config.js
plugins: [
   { src: '@plugins/quill-editor.js', mode: 'client' },
]

Upvotes: 2

Views: 3150

Answers (2)

Ahad
Ahad

Reputation: 119

I solved this issue by adding

ssr: false

in nuxt.config.js because vue2 doesn't support server-side rendering

Upvotes: 0

sudhakar selva
sudhakar selva

Reputation: 397

let VueEditor

if (process.client) {
    VueEditor = require('vue2-editor').VueEditor
}

not doing anything in nuxt config or any plugin. only import method changed. its working now but i am still wondering why it is not working when i disable ssr in nuxt -config.js file

Upvotes: 3

Related Questions