2

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' },
]

2 Answers 2

3
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

Sign up to request clarification or add additional context in comments.

1 Comment

PS: please do not use require in 2021. More up to date answer available here.
0

I solved this issue by adding

ssr: false

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

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.