codemirror如何安装

codemirror如何安装

我不知道该怎么办:

<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script>
  var editor = CodeMirror.fromTextArea(myTextarea, {
    mode: "text/html"
  });
</script>

有人能帮我吗?

最佳答案

这是否为您指明了正确的方向?

        <link rel="stylesheet" href="lib/codemirror.css">
        <script src="lib/codemirror.js"></script>
        <script src="mode/javascript/javascript.js"></script>
        <script src="addon/fold/foldcode.js"></script>
    </head>
    <body>
        <form style="width:500px;">
            <textarea id="code" name="code">
alert("HI");
//says HII
            </textarea>
        </form>

        <script>
            window.onload = function() {
                window.editor = CodeMirror.fromTextArea(code, {
                    mode: "javascript",
                    lineNumbers: true,
                    lineWrapping: true,
                    foldGutter: {
                        rangeFinder: new CodeMirror.fold.combine(CodeMirror.fold.brace, CodeMirror.fold.comment)
                    },
                    gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
                });
            };
        </script>
    </body>
</html>

关于javascript - codemirror如何安装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21085170/

10-11 12:58