从VUE 2中获取摩纳哥编辑的值
我是Vuejs的新手,必须将VUE2与摩纳哥编辑整合。 我想获得用户输入的值。我尝试了几种方法,但无法获得价值。提前致谢!
这是我的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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
getValue()
方法,摩纳哥编辑器已内置的方法很容易获得值。我在数据部分中设置了您的变量,并添加了
createeditor
和geteDitorValue
方法,它们将帮助您更好地组织代码。It is very easy to get the value with the
getValue()
method that monaco editor has built-in.I set your variables in the data section and added a
createEditor
andgetEditorValue
method, they will help you to organize better your code.