Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

411
Views
Obtenga valores de Monaco Editor en Vue 2

Soy nuevo en Vuejs y tengo que integrar Vue2 con Monaco Editor. Quiero obtener valores ingresados por el usuario. Intenté varias formas pero no puedo obtener el valor. ¡Gracias por adelantado!

Este es mi archivo Editor.vue.

 <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 answers
Answer question

0

Creo que lo puedes lograr de una forma muy sencilla asignando el editor a una variable, sería algo así:

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()
  }
}

Es importante que notes que en el método getEditorValue() hacemos uso del método nativo getValue() de monaco editor, este nos entrega el valor de la instancia del editor. Espero que sea lo que buscas.

about 4 years ago · Jonathan Arias Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!