use*_*122 1 ace-editor angularjs typescript angular9
我在将 ace 编辑器设置为只读模式时遇到问题。我正在使用 Angular 9 并尝试了以下方法:
在 HTML 文件中我有:
<ace-editor mode="java" theme="monokai" id="codeEditor"></ace-editor>
Run Code Online (Sandbox Code Playgroud)
在我的打字稿文件中,我有:
import * as ace from 'ace-builds/src-noconflict/ace';
...
ngOnInit() {
var editor = ace.edit('codeEditor');
editor.getSession().setUseWorker(false);
editor.setShowPrintMargin(false);
editor.setReadOnly(true);
}
Run Code Online (Sandbox Code Playgroud)
但是,当模板加载时,我仍然可以在我的 ace 编辑器中编写代码。
检查 setReadOnly 代码之前是否有错误,或者您的某些代码是否将 readOnly 更改回 false,因为您的示例中的代码在下面的示例中有效
<script src=https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js></script>
<div id=codeEditor style=height:80vh></div>
<script>
var editor = ace.edit('codeEditor');
editor.session.setUseWorker(false);
editor.setShowPrintMargin(false);
editor.setReadOnly(true);
</script>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6066 次 |
| 最近记录: |