Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

461
Vistas
VueEditor document is not defined Nuxt.js

In my Nuxt.js project I installed vue2-editor package to be able to write articles with HTML. When I come to page, write something and press the button everything works correctly, but when I reload page, I get document is not defined error.

Here is the code:

<template>
  <div>
    <SideBar />
    <div class='content'>
      <h1>Write article</h1>
      <client-only>
        <VueEditor
          v-model='articleContent'
        />
      </client-only>
      <div style='margin-top: 15px'><button @click='postArticle'>Post article</button></div>
    </div>
  </div>
</template>

<script>
import { VueEditor } from 'vue2-editor';
import SideBar from '../components/SideBar';
export default {
  name: 'Articles',
  components: {
    SideBar,
    VueEditor
  },
  data() {
    return {
      articleContent: null,
    }
  },
  methods: {
    postArticle() {
      console.log(this.articleContent)
    },
  },
}
</script>

And the error looks like that:

enter image description here

Also in documentation I've found that for Nuxt.js projects vue2-editor should be added to modules, and I did it, but it still doesn't work:

  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    'vue2-editor/nuxt'
  ],
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can try to load it dynamically:

<template>
  <div>
    <SideBar />
    <div class='content'>
      <h1>Write article</h1>
      <client-only>
        <VueEditor
          v-model='articleContent'
        />
      </client-only>
      <div style='margin-top: 15px'><button @click='postArticle'>Post article</button></div>
    </div>
  </div>
</template>

<script>
import SideBar from '../components/SideBar';
export default {
  name: 'Articles',
  components: {
    SideBar,
    VueEditor: () => process.client ? (await import("vue2-editor")).VueEditor : ""
  },
  data() {
    return {
      articleContent: null,
    }
  },
  methods: {
    postArticle() {
      console.log(this.articleContent)
    },
  },
}
</script>
about 4 years ago · Juan Pablo Isaza Denunciar

0

Do follow the below steps the add that plugin into your Nuxt

  • There will be plugins folder just like pages and components, if not create one and add a js file into it vue2-editor.js.
  • Copy the below content inside vue2-editor.js
      import Vue from "vue";
      import Vue2Editor from "vue2-editor";
    
      Vue.use(Vue2Editor);
    
  • Inside nuxt.config.js remove the 'vue2-editor/nuxt' from the modules and create a separate array called plugins as below
  /*
  ** Plugins to load before mounting the App
  */
 plugins: [{ src: "~/plugins/vue2-editor", mode: 'client' }],
  • Thats it you are done. Now you can start using it in any of the vue files like
  <vue-editor placeholder="Write Something..." v-model="content"></vue-editor>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda