1、项目需要使用monaco-editor,手动封装了一下
<template>
<div ref="monacoEditorRef" :style="style"></div>
</template>
<script>
import * as monaco from 'monaco-editor';
import { debounce } from 'lodash';
export default {
name: 'Monaco',
props: {
width: { type: [String, Number], default: '100%' },
height: { type: [String, Number], default: '100%' },
code: { type: String, default: '// code \n' },
language: { type: String, default: 'javascript' },
theme: { type: String, default: 'vs-dark' }, // vs, hc-black
options: { type: Object, default: () => ({}) },
highlighted: {
type: Array,
default: () => [
{
number: 0,
class: ''
}
]
},
changeThrottle: { type: Number, default: 0 },
viewMode: { type: Boolean, default: false }
},
data() {
return