【问题标题】:CSS Plus - Uncaught ReferenceError: CodeMirror is not definedCSS Plus - 未捕获的 ReferenceError:未定义 CodeMirror
【发布时间】:2016-06-24 11:09:21
【问题描述】:

我搜索了 Google 和这些论坛都没有运气。这是我的代码,错误似乎源于此。在源文件中挖掘是没有帮助的。这安装在多站点 WordPress 上,并与管理区域中的帖子等一起使用。所有网站在发布等时都会抛出此错误。

var editor = CodeMirror.fromTextArea(

                document.getElementById("code"), {  

                    lineNumbers: true,

                    mode: "text/x-scss", 

                    theme: "solarized light", 

                    lineWrapping: true,  

                    onCursorActivity: function() {    

                        editor.setLineClass(hlLine, null, null);    

                        hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");  }

                    });

              var hlLine = editor.addLineClass(0, "background", "activeline");

                editor.on("cursorActivity", function() {

                    var cur = editor.getLineHandle(editor.getCursor().line);

                        if (cur != hlLine) {

                            editor.removeLineClass(hlLine, "background", "activeline");

                            hlLine = editor.addLineClass(cur, "background", "activeline");

                        }

                    });

              var number = jQuery(".CodeMirror-wrap").length;

              if(number > 1){

                jQuery(".CodeMirror-wrap").hide();

                jQuery(".CodeMirror-wrap:first").show();

              }

CSS Plus WordPress plugin

非常感谢任何见解。

【问题讨论】:

标签: jquery codemirror


【解决方案1】:

您需要在您的站点中包含 CodeMirror 库,然后才能将此代码与 css 插件一起执行。前往http://codemirror.net/doc/compress.html 并选择核心库、css 模式和活动线路插件。

您还需要在样式表中包含https://codemirror.net/lib/codemirror.css。

【讨论】:

  • 我没有运气就按照您的指示进行操作。我最终禁用了 codemirror 以恢复工作。我稍后会深入研究它。感谢您的反馈。
  • 我遇到了类似的问题,我在这里发布了它:stackoverflow.com/q/69430941/7584240 如果你有机会,请看看并提供一些解决方案。
猜你喜欢
  • 2012-08-31
  • 2021-07-25
  • 2023-01-23
  • 2016-11-03
  • 2011-01-05
  • 2016-01-02
  • 2013-10-06
  • 2016-12-17
相关资源
最近更新 更多