我在我的 Angular 应用程序中成功导入了第三方库(Eclipse Orion 编辑器),它运行良好——我可以编辑文本并使用它。然而,由于Uncaught ReferenceError: define is not defined
. 编辑器无法加载语法突出显示。
我已经尝试包含 requirejs,但这样做该应用程序甚至不再启动。
我在我的中包括以下几行angular-cli.json
:
"scripts": [
"../orion/editor/stylers/lib/syntax.js",
"../orion/editor/stylers/application_xml/syntax.js",
"../orion/editor/built-editor.min.js"
],
在我提供编辑器的组件中:
ngOnInit() {
System.import('../../../orion/editor/stylers/lib/syntax.js');
System.import('../../../orion/editor/stylers/application_xml/syntax.js');
System.import('../../../orion/editor/built-editor.js')
.then((o: any) => {
this.orionEditor = o({
document: document, className: 'editor', parent: 'xml', content-type: 'application/xml'
})[0];
this.orionEditor.setText(this.innerValue);
});
}
所有这一切都很好,除了define is not defined
错误和随之而来的Error: undefined missing orion/editor/stylers/application_xml/syntax
错误。
有没有人有加载在 Angular 中使用 requirejs 的库的经验并且可以在这里帮助我?
GitHub 上提供了一个演示此问题的简单示例。