Closed 1076965238 closed 1 year ago
java 需要使用 clike语言包,官网示例: https://codemirror.net/5/mode/clike/index.html
具体代码如下:
<template>
<div>
java lang:
<Codemirror
v-model:value="code"
:options="cmOptions"
border
:height="600"
@change="onChange"
>
</Codemirror>
</div>
</template>
<script lang="ts" setup>
import Codemirror from "codemirror-editor-vue3";
// language
import { EditorConfiguration } from "codemirror";
import "codemirror/mode/clike/clike.js";
// theme
const code = ref(`import com.demo.util.MyType;
import com.demo.util.MyInterface;
public enum Enum {
VAL1, VAL2, VAL3
}
public class Class<T, V> implements MyInterface {
public static final MyType<T, V> member;
private class InnerClass {
public int zero() {
return 0;
}
}
@Override
public MyType method() {
return member;
}
public void method2(MyType<T, V> value) {
method();
value.method3();
member = value;
}
}
`);
const cmOptions: EditorConfiguration = {
mode: "text/x-java",
};
/** @description */
const onChange = (...args) => {
console.log(" args", args);
};
</script>
好的,感谢
请问能支持java代码编写吗