首页 > 解决方案 > 如何配置 [mode]="'sql'" 在 Angular 7 中使用 ng2-ace-editor?

问题描述

当我使用 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 中配置模式?

标签: javascriptangularace-editor

解决方案


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

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

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

推荐阅读