javascript 未捕获的 ReferenceError: CodeMirror 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12297080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:50:36  来源:igfitidea点击:

Uncaught ReferenceError: CodeMirror is not defined

javascripthtmlcodemirror

提问by user1159517

I am trying to include CodeMirror Plugin but am getting this error Uncaught ReferenceError: CodeMirror is not defined

我正在尝试包含 CodeMirror 插件,但出现此错误 Uncaught ReferenceError: CodeMirror is not defined

My HTML CODE is here

我的 HTML 代码在这里

http://pastie.org/4673008

http://pastie.org/4673008

Can anyone help ??

有人可以帮忙吗??

Thanks in advance..

提前致谢..

回答by Savjee

You're loading the clike module before CodeMirror itself.

您正在 CodeMirror 本身之前加载 clike 模块。

Change the order in your HTML head from this:

从此更改 HTML 头中的顺序:

<script type="text/javascript" src="../CodeMirror-2.33/mode/clike/clike.js"></script>
<script type="text/javascript" src="../CodeMirror-2.33/lib/codemirror.js"></script>
<script type="text/javascript" src="../CodeMirror-2.33/mode/javascript/javascript.js"></script>

To this:

对此:

<script type="text/javascript" src="../CodeMirror-2.33/lib/codemirror.js"></script>
<script type="text/javascript" src="../CodeMirror-2.33/mode/clike/clike.js"></script>
<script type="text/javascript" src="../CodeMirror-2.33/mode/javascript/javascript.js"></script>

回答by Chetan Kumar

ngx-codemirrorSQL high-late is not working, deeper I found the to the code mirror tag the class to high-late syntax cm-default, cm-link, cm-keyword these class is not appending. config used : public queryConfig = { lineNumbers: true, theme: 'twilight', mode: 'text/x-sql', lineWrapping : true, autoFocus: true };

ngx-codemirrorSQL high-late 不起作用,更深入地我发现代码镜像标记类到 high-late 语法 cm-default、cm-link、cm-keyword 这些类没有附加。使用的配置:public queryConfig = { lineNumbers: true, theme: 'twilight', mode: 'text/x-sql', lineWrapping : true, autoFocus: true };

The main.tsfile added the imports below:

main.ts文件添加了以下导入:

main.ts scripts

main.ts 脚本

The angularcli.jsonfile added the scripts below:

angularcli.json文件添加了以下脚本:

angularcli.json scripts

angularcli.json scripts