feat: 代码编辑器
This commit is contained in:
parent
caf400f9d3
commit
2f11c433fd
@ -1,28 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="main">
|
<code-mirror basic :lang="lang" v-model="codeVal" :theme="theme" :extensions="extensions" />
|
||||||
<code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" :extensions="extensions" />
|
|
||||||
</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 { oneDark } from "@codemirror/theme-one-dark";
|
||||||
import { json } from "@codemirror/lang-json";
|
import { json } from "@codemirror/lang-json";
|
||||||
|
|
||||||
defineOptions({ name: "CodemirrorCode" });
|
defineOptions({ name: "CodemirrorCode" });
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
initJson: {
|
initJson: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// const initJson = {
|
|
||||||
// name: `maybaby`,
|
|
||||||
// year: 25,
|
|
||||||
// weight: 45,
|
|
||||||
// height: 165
|
|
||||||
// };
|
|
||||||
// 初始化
|
// 初始化
|
||||||
let codeVal = ref("");
|
let codeVal = ref("");
|
||||||
// 转成json字符串并格式化
|
// 转成json字符串并格式化
|
||||||
@ -54,13 +46,4 @@ const theme = {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
.main {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
/* required! */
|
|
||||||
.cm-editor {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
3
src/vite-env.d.ts
vendored
3
src/vite-env.d.ts
vendored
@ -8,3 +8,6 @@ declare module "*.vue" {
|
|||||||
declare module "vue-i18n";
|
declare module "vue-i18n";
|
||||||
declare module "@arco-design/color";
|
declare module "@arco-design/color";
|
||||||
declare module "sortablejs";
|
declare module "sortablejs";
|
||||||
|
declare module "vue-codemirror6";
|
||||||
|
declare module "@codemirror/theme-one-dark";
|
||||||
|
declare module "@codemirror/lang-json";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user