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' },
]
sudhakar selva
  • 387
  • 4
  • 16

2 Answers2

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

sudhakar selva
  • 387
  • 4
  • 16
  • PS: please do not use `require` in 2021. More up to date answer available [here](https://stackoverflow.com/a/69307486/8816585). – kissu Dec 07 '21 at 01:20
0

I solved this issue by adding

ssr: false

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

Ahad
  • 49
  • 1
  • 6