我无法在codemirror中突出显示模板文字字符串。除了无法突出显示模板文字语法之外,它对所有内容都非常有效。
示例:它不会突出显示此字符串:
var p = `<div>sometext</div>`
我的初始化代码如下所示。
JSeditor = CodeMirror(document.getElementsByClassName("control-code")[0], {
value: "function myScript(){return 100;}\n",
tabMode: "indent",
mode: "text/javascript",
keyMap: "sublime",
theme: "monokai",
tabSize: 2,
gutters: ["CodeMirror-lint-markers", "CodeMirror-linenumbers", "CodeMirror-foldgutter"],
styleActiveLine: true,
lineNumbers: true,
lineWrapping: true,
autoCloseTags: true,
foldGutter: true,
dragDrop: true,
lint: true,
autoCloseBrackets: true,
matchBrackets: true,
showCursorWhenSelecting: true,
showInvisibles: true,
maxInvisibles: 16 // optional
});
我也在使用js-lint进行验证。它给了我模板文字字符串的错误:
"template literal syntax is only available in es6 (us esversion 6)"