Twitter bootstrap text代码镜像和引导2.3之间的区域冲突

Twitter bootstrap text代码镜像和引导2.3之间的区域冲突,twitter-bootstrap,textarea,codemirror,twitter-bootstrap-2,Twitter Bootstrap,Textarea,Codemirror,Twitter Bootstrap 2,我正在尝试使用CodeMirror在文本区域中突出显示语法。我还在文本区域使用Bootstrap 2.3。我在Bootstrap显示的文本区域中获取代码,但在Chrome控制台中没有在CodeMirror中突出显示语法,而是出现以下错误: 未捕获类型错误:无法设置未定义的属性“display” 这是我用于给定表单的Javascript,对象为null var myCodeMirror = CodeMirror.fromTextArea($('#formId'), { mode: {nam

我正在尝试使用CodeMirror在文本区域中突出显示语法。我还在文本区域使用Bootstrap 2.3。我在Bootstrap显示的文本区域中获取代码,但在Chrome控制台中没有在CodeMirror中突出显示语法,而是出现以下错误:

未捕获类型错误:无法设置未定义的属性“display”

这是我用于给定表单的Javascript,对象为null

var myCodeMirror = CodeMirror.fromTextArea($('#formId'), {
    mode: {name: "python",
           version: 2,
           singleLineStringErrors: false},
    lineNumbers: true,
    //indentUnit: 4,
    smartIndent: true,
    tabSize: 2,
    indentWithTabs: true,
    tabMode: "shift",
    autofocus: true,
    matchBrackets: true
  });

为了找到错误,获取完整的代码集将非常有用。见:

我唯一能做的就是提供一段引导和codemirror实际协同工作的代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
  <link rel=stylesheet href="//codemirror.net/doc/docs.css">
  <link rel=stylesheet href="//codemirror.net/lib/codemirror.css">
  <link rel=stylesheet href="//codemirror.net/theme/night.css">
  <script src="//codemirror.net/lib/codemirror.js"></script>
  <script src="//codemirror.net/mode/python/python.js"></script>
</head>
<body>
<div class="container">
  <h2>Form control: textarea</h2>
  <p>The form below contains a textarea for python:</p>
  <form role="form">
    <div class="form-group">
      <label for="comment">Comment:</label>
      <textarea class="form-control" rows="5" id="comment">
# indent your Python code to put into an email
import glob
# glob supports Unix style pathname extensions
python_files = glob.glob('*.py')
for file_name in sorted(python_files):
    print '    ------' + file_name

    with open(file_name) as f:
        for line in f:
            print '    ' + line.rstrip()

    print
</textarea>
    </div>
  </form>
</div>  
    <script>
      var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('comment'), {
        mode: {name: "python",
          version: 2,
          singleLineStringErrors: false},
        lineNumbers: true,
        //indentUnit: 4,
        smartIndent: true,
        tabSize: 2,
        indentWithTabs: true,
        tabMode: "shift",
        autofocus: true,
        matchBrackets: true        
      });
    </script>
</body>
</html>

表单控件:textarea
下表包含python的文本区域:

评论: #缩进Python代码以放入电子邮件 导入glob #glob支持Unix样式的路径名扩展 python_files=glob.glob('*.py') 对于排序后的文件名(python文件): 打印'----'+文件名 打开(文件名)为f时: 对于f中的行: 打印“”+行.rstrip() 打印 var mycodemiror=codemirr.fromTextArea(document.getElementById('comment'){ 模式:{name:“python”, 版本:2, singleLineStringErrors:false}, 行号:对, //单位:4, 智能缩进:没错, tabSize:2, indentWithTabs:true, tabMode:“shift”, 自动对焦:对, 对 });
错误消息是否带有行号?是的,是我上面发布的代码的第一行。