本页导航
article
monacoEditor
AI摘要
本文介绍了 monacoEditor 在线代码编辑器的功能和使用方法。通过 Vue 组件形式引入,支持多种参数配置,包括尺寸、主题和编辑选项。默认配置满足大多数开发需求,同时提供灵活的自定义能力,方便开发者在项目中快速集成高效的代码编辑体验。
说明
在线代码编辑器
使用
<script setup lang="ts">
import { MonacoEditor } from "liyao-vue-common"
</script>
<template>
<MonacoEditor />
</template>
可选参数
export const editorProps = {
width: {
type: [String, Number] as PropType<string | number>,
default: '100%'
},
height: {
type: [String, Number] as PropType<string | number>,
default: '500px'
},
theme: {
type: String as PropType<Theme>,
validator(value: string): boolean {
return ['vs', 'hc-black', 'vs-dark'].includes(value)
},
default: 'vs-dark'
},
options: {
type: Object as PropType<Partial<Options>>,
default() {
return {
automaticLayout: true,
foldingStrategy: 'indentation',
renderLineHighlight: 'all',
selectOnLineNumbers: true,
minimap: {
enabled: false
},
readOnly: false,
contextmenu: true,
fontSize: 16,
scrollBeyondLastLine: false,
overviewRulerBorder: false
}
}
}
}
更多配置请查看MonacoEditor官方文档
最后更新于 2025-09-30 20:31