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

413
Vistas
Get values from Monaco Editor in Vue 2

I am new to Vuejs and have to integrate Vue2 with Monaco Editor. I want to get values input by user. I tried few ways but cannot get the value. Thanks in advance!

This is my Editor.vue file.

<template>
  <div id="editor" ref="editor"></div>
</template>

<script>
import * as monaco from "monaco-editor";

export default {
  name: "CodeEditor",
  mounted() {
    const editorOptions = {
      value: [
        "function greeting() {",
        '\tconsole.log("Test Monaco...);',
        "}",
      ].join("\n"),
      language: "text/javascript",
      minimap: { enabled: false },
      wordWrap: true,
      automaticLayout: true,
    };
    window.editor = monaco.editor.create(document.getElementById("editor"), editorOptions);
  },

  computed: {   
    getUserInput() {
      // how to get user input???
    },
  },
};
</script>

<style>
#editor {
  height: 500px;
  width: 100%;
  overflow: hidden;
}
</style>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you can achieve it in a very simple way by assigning the editor to a variable, it would be something like this:

 import * as monaco from "monaco-editor"; export default { name: "CodeEditor", data() { return { editor: null, editorOptions: { value: [ "function greeting() {", '\tconsole.log("Test Monaco...);', "}", ].join("\n"), language: "text/javascript", minimap: { enabled: false }, wordWrap: true, automaticLayout: true } } }, methods: { createEditor() { this.editor = monaco.editor.create(document.getElementById("editor"), this.editorOptions); }, getEditorValue() { // Ejecutas el método getValue() que es nativo de monaco editor return this.editor.getValue() } }, mounted() { this.createEditor() } }

It is important that you note that in the getEditorValue() method we make use of monaco editor's native getValue() method, which gives us the value of the editor instance. I hope it's what you want.

about 4 years ago · Jonathan Arias 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