我在项目中使用ng2-ace-editor。我需要在出现错误的行号之前显示错误或警告指示。
var Range = ace.require('ace/range').Range;
this.highlight.getEditor().session.addMarker(
new Range(0, 0, 2, 1), "myMarker", "fullLine"
);
这在编辑器中没有执行任何操作。这就是在页面中调用编辑器的方式。
this.editor.getEditor().setOptions({
enableBasicAutocompletion: editorOption.snippet,
highlightActiveLine: editorOption.highlight,
showLineNumbers: editorOption.line,
enableSnippets: editorOption.snippet,
enableLiveAutocompletion: editorOption.snippet,
behavioursEnabled: editorOption.behaviours,
wrapBehavioursEnabled: editorOption.wrapb,
autoScrollEditorIntoView: editorOption.auto,
wrap: editorOption.wrap,
keyboardHandler: null,
readOnly: editorOption.readonly
});
预先感谢您的帮助。
答案 0 :(得分:1)
要显示错误或警告符号,可以使用setAnnotations:
this.editor._editor.getSession().setAnnotations([{
row: 1,
column: 0,
text: "Error Message", // Or the Json reply from the parser
type: "error" // also "warning" and "information"
}]);
要获得会话,您可以使用
var _session = _editor.getSession();
答案 1 :(得分:1)
可以使用-
调用角度6中的ace编辑器的设置注释。 this.editor._editor.session.setAnnotations([{
row: 1,
column: 0,
text: "Error Message", // Or the Json reply from the par
type: "error" // also "warning" and "information"
}]);
答案 2 :(得分:0)
我可以通过添加装订线信息来解决此问题。
this.editor._editor.session.addGutterDecoration( elementPosition, "fa fa-fire text-info gutterMessages");
感谢您的宝贵时间! :)