feat: CodemirrorCode组件
This commit is contained in:
parent
e3d4e0947e
commit
a94a33b15c
@ -1,11 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" />
|
<code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" :extensions="extensions" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import CodeMirror from "vue-codemirror6";
|
import CodeMirror from "vue-codemirror6";
|
||||||
|
import { oneDark } from '@codemirror/theme-one-dark'
|
||||||
import { json } from "@codemirror/lang-json";
|
import { json } from "@codemirror/lang-json";
|
||||||
|
|
||||||
defineOptions({ name: "CodemirrorCode" });
|
defineOptions({ name: "CodemirrorCode" });
|
||||||
@ -28,6 +29,8 @@ let codeVal = ref("");
|
|||||||
codeVal.value = JSON.stringify(props.initJson, null, "\t");
|
codeVal.value = JSON.stringify(props.initJson, null, "\t");
|
||||||
// json
|
// json
|
||||||
const lang = json();
|
const lang = json();
|
||||||
|
// 扩展
|
||||||
|
const extensions = [oneDark];
|
||||||
// 主题样式设置
|
// 主题样式设置
|
||||||
const theme = {
|
const theme = {
|
||||||
"&": {
|
"&": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user