Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

412
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda