【问题标题】:How to config [mode]="'sql'" use ng2-ace-editor in angular 7?如何配置 [mode]="'sql'" 在 Angular 7 中使用 ng2-ace-editor?
【发布时间】:2019-04-17 04:10:15
【问题描述】:

当我使用 ng2-ace-editor 时。有配置

<div ace-editor
       [(text)]="text"
       [mode]="'sql'"
       [theme]="'eclipse'"
       [options]="options"
       [readOnly]="false"
       [autoUpdateContent]="true" 
       [durationBeforeCallback]="1000"
       (textChanged)="onChange($event)"
       style="min-height: 20px; max-height: 20px; width:100%; overflow: auto;"></div>

但是有console.log

http://localhost:4200/mode-sql.js net::ERR_ABORTED 404 (Not Found)
http://localhost:4200/mode-html.js net::ERR_ABORTED 404 (Not Found)

如何在 ng2-ace-editor 中配置模式?

【问题讨论】:

  • 您能否添加有关加载 ace 方式的更多信息,从错误看来 basePath 配置不正确
  • 我用 angular-cli 在项目 angular 的 angular.json 中添加了 ace 我不了解自定义 1 模式下 angular 7 中 ace 的操作机制。
  • 看起来像 github.com/fxmontigny/ng2-ace-editor 包中的错误,因为即使在 repo 中的示例中也会引发错误,请尝试在 github 上报告问题

标签: javascript angular ace-editor


【解决方案1】:

您需要导入您在编辑器中使用的所需modes/themes

将此代码放入使用Ace editor的组件中,然后重试:

import 'brace';
import 'brace/mode/sql';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    • 1970-01-01
    相关资源
    最近更新 更多