Closed qzd1989 closed 2 months ago
要用 class 去改,产生作用的是组件下一级的.CodeMirror
标签上的font-family
属性,示例如下:
<template>
<div class="h-500px w-300px">
<Codemirror
originalStyle
:options="cmOptions"
class="cm-component"
@ready="onReady"
@scroll="onScroll"
v-model:value="code"
:border="true"
/>
</div>
</template>
<script lang="ts">
import { ref, defineComponent } from "vue";
import { Editor, EditorSelectionChange } from "codemirror";
import Codemirror from "codemirror-editor-vue3";
// language
import "codemirror/mode/javascript/javascript.js";
import "codemirror/addon/selection/active-line";
// theme
// import "codemirror/theme/";
export default defineComponent({
components: {
Codemirror,
},
setup() {
const code = ref(`function findSequence(goal) {
function find(start, history) {
if (start == goal)
return history;
else if (start > goal)
return null;
else
return find(start + 5, "(" + history + " + 5)") ||
find(start * 3, "(" + history + " * 3)");
}
return find(1, "1");
}`);
return {
code,
cmOptions: {
mode: "javascript",
lineNumbers: true,
highlightDifferences: true,
lineWiseCopyCut: true,
styleActiveLine: true,
},
onReady(cm: any) {
const cminstance: Editor = cm;
console.log(cminstance.getValue());
},
onScroll(cm: any) {
console.log(cm);
},
};
},
});
</script>
<style lang="less" scoped>
:deep(.cm-component) {
font-size: 13px;
font-family: Menlo !important;
.CodeMirror {
font-family: Menlo !important;
}
}
</style>
谢谢.
Describe the bug
无论我怎么修改,都没有效果. 这几个是内置通用字体,用于其他元素上都正常显示..
Steps to reproduce
问题样式截图
正常样式截图
Package Info
Validations