Comments (5)
I have dug into the "codemirror", and found that it doesn't support SSR.
However, I am still confused with the css compile issue.
from codemirror-editor-vue3.
I am now trying to use the dynamic import import('codemirror-editor-vue3')
to solve this problem. but how can i define CodeMirror's language? as i can't get the CodeMirror object !
from codemirror-editor-vue3.
As you said, Codemirror itself does not support SSR, and I have not intended to do this.
As for the dynamic introduction you said, I don't understand it, it is best to provide Demo.
from codemirror-editor-vue3.
As we can see, I couldn't use CodeMirror on SSR. and couldn't import the codemirror with static import
as below:
import CodeMirror from 'codemirror';
Instead, dynamic import
import('codemirror').then((CodeMirror)=>{ CodeMirror.doSomething() })
Hope I made it clear.
from codemirror-editor-vue3.
The parent component:
<template>
<button @click="visible = !visible">show modal</button>
<codemirrorDemo v-if="visible" />
</template>
<script lang="ts" setup>
import codemirrorDemo from "./codemirrorDemo.vue";
const visible = ref(false);
</script>
Child components(codemirrorDemo.vue
):
<template>
<Codemirror v-model:value="code" :options="cmOptions" border :height="200" />
</template>
<script lang="ts">
import { ref } from "vue";
import "codemirror/mode/javascript/javascript.js";
const res = await import("codemirror-editor-vue3");
export default defineComponent({
components: {
Codemirror: res.default,
},
setup() {
const code = ref(`const obj = {
name: "peter",
age: 18
};
`);
const cmOptions = {
mode: "javascript", // 语言模式
lineNumbers: true, // 显示行号
smartIndent: true, // 智能缩进
indentUnit: 2, // 智能缩进单位为4个空格长度
foldGutter: true, // 启用行槽中的代码折叠
styleActiveLine: true, // 显示选中行的样式
};
return {
code,
cmOptions,
};
},
});
</script>
from codemirror-editor-vue3.
Related Issues (20)
- type define error ts定义错误 HOT 2
- Why deafult height 200? HOT 2
- replaceSelection() 插入数据有具体的使用方式吗 HOT 4
- 请问大佬vue的模板如何支持语法高亮,现在的语言包语法高亮总是不对 HOT 3
- 编辑器提示功能配置设置问题 HOT 1
- 请问是否支持高亮某个关键字或支持v-html HOT 1
- when delete all code, change emits not correct, HOT 5
- Can't resolve 'codemirror/mode/javascript/javascript.js' HOT 1
- 火狐浏览器兼容问题 HOT 1
- 关于placeholder失效问题 HOT 1
- 请问能支持java代码编写吗 HOT 2
- 根据示例编引入组件提示Missing "./mode/javascript/javascript.js" export in "codemirror" package HOT 5
- 编辑器代码内容无法高亮,已引入相关js HOT 5
- 运行官网ts setup示例报错 HOT 2
- Failure when trying to pass tests with vitest in vue 3 project HOT 1
- Focus the editor HOT 2
- 使用WebStorm/IDEA生成的Vite+TS工程不支持语法高亮 HOT 4
- change event is not triggered HOT 2
- 2.3.1 is broken HOT 4
- 发现好多codemirror的属性都没有 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codemirror-editor-vue3.