我正在使用Code Mirror插件来编辑页面的HTML源代码.HTML代码从数据库中获取并在代码镜像中设置为值.但是,设置值后,它将以与数据库中保存的格式相同的格式显示.如何以正确的格式显示?提前致谢.
Fra*_*len 10
有一个叫做的函数 autoFormatRange
editor.autoFormatRange(range.from, range.to);
Run Code Online (Sandbox Code Playgroud)
CodeMirror Group中的这个片段可能就是您所需要的:
function autoFormat() {
var totalLines = editor.lineCount();
var totalChars = editor.getTextArea().value.length;
editor.autoFormatRange({line:0, ch:0}, {line:totalLines, ch:totalChars});
}
Run Code Online (Sandbox Code Playgroud)
http://codemirror.net/2/demo/formatting.html
| 归档时间: |
|
| 查看次数: |
8842 次 |
| 最近记录: |