我是开发 angular2+ 和 ace 的新手。当我将 ace 编辑器嵌入到我的 Angular 应用程序中时,我遇到了“ace 未定义”的错误。
我使用的系统是ubuntu gnome 16.04 我实现它的步骤是: 1.intall ace-builds 使用 npm 2. 将路径从 node-module 复制到 angular-cli.json(最重要的是,来自 src-min-noconflict 的 ace.js。 3.构建一个编辑器组件,editor.component.ts中的代码是这样的:
declare const ace:any;
@Component({....})
export class EditorComponent implements OnInit {
editor:any;
......
ngOnInit() {
this.editor = ace.edit("editor");
}
}
控制台显示在“this.editor =.....”这一行中抛出了错误
我一直在尝试其他一些最新版本的 ace,但没有成功。有没有人知道如何解决它?我将非常感谢您的帮助!
最佳答案
ace is not defined
可以通过在组件中导入 ace 插件文件来避免错误。
import ace from 'ace-builds/src-min-noconflict/ace';
import "brace/mode/{mode_name}";
import "brace/snippets/{mode_name}";
import "brace/ext/language_tools";
关于typescript - 角度 5 项目中的错误 "ace is not defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49805925/