Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 8中的插件:未捕获引用错误:SystemJS_Angular_Typescript_Plugins - Fatal编程技术网

Angular 8中的插件:未捕获引用错误:SystemJS

Angular 8中的插件:未捕获引用错误:SystemJS,angular,typescript,plugins,Angular,Typescript,Plugins,我按照本教程将插件安装到angular应用程序中,我想要的是angular应用程序中的一个组件,它执行并显示一个外部组件 问题是我犯了一个错误: Uncaught ReferenceError: SystemJS is not defined at Module../src/main.ts (main.ts:13) at __webpack_require__ (bootstrap:78) at Object.0 (parent.service.ts:13) at

我按照本教程将插件安装到angular应用程序中,我想要的是angular应用程序中的一个组件,它执行并显示一个外部组件

问题是我犯了一个错误:

Uncaught ReferenceError: SystemJS is not defined
    at Module../src/main.ts (main.ts:13)
    at __webpack_require__ (bootstrap:78)
    at Object.0 (parent.service.ts:13)
    at __webpack_require__ (bootstrap:78)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.js:1
我的主菜

声明const SystemJS:any;
从“@angular/core”导入*作为angularCore;
从“@angular/common”导入*作为angularcomon;
从“@angular/forms”导入*作为angularForms;
SystemJS.set('@angular/core',SystemJS.newModule(angularCore));
SystemJS.set('@angular/common',SystemJS.newModule(angularcomon));
SystemJS.set('@angular/forms',SystemJS.newModule(angularForms));
angular.json的一部分
“样式”:[
“node_modules/bootstrap/dist/css/bootstrap.css”,
“src/styles.css”,
“节点\u模块/font-awesome/css/font-awesome.css”
],
“脚本”:[
“node_modules/jquery/dist/jquery.js”,
“node_modules/popper.js/dist/umd/popper.js”,
“node_modules/bootstrap/dist/js/bootstrap.js”,
“node_modules/systemjs/dist/system.js”
]
我的app.component.ts

进口{
组件、编译器、注入器、ViewChild、,
ViewContainerRef,AfterViewInit
}从“@angular/core”开始;
声明const SystemJS:any;
@组成部分({
选择器:'应用程序根',
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent实现AfterViewInit{
标题='angularExtensionv3';
@ViewChild('content',{static:false})content:ViewContainerRef;
构造函数(专用编译器:编译器,专用注入器:注入器){
}
ngAfterViewInit(){
这是loadPlugins();
}
专用异步loadPlugins(){
//导入外部模块包
const module=await SystemJS.import('assets/plugins/plugin-a.bundle.js');
//编译模块
const moduleFactory=等待此消息。\u编译器
.compileModuleAsync(模块['PluginAModule']);
//解析组件工厂
const moduleRef=moduleFactory.create(this.\u);
//获取定制的提供程序名称“插件”
const componentProvider=moduleRef.injector.get('plugins');
//从插件阵列加载位置0上的组件
const componentFactory=moduleRef.componentFactoryResolver
.组件工厂(
componentProvider[0][0]。组件
);
//编译组件
var pluginComponent=this.content.createComponent(componentFactory);
//发送@Input()值
//pluginComponent.instance.anyInput=“inputValue”;
//访问组件模板视图
//(pluginComponent.hostView作为EmbeddedViewRef),rootNodes[0]作为HtmleElement;
}
}
有人可以帮我修复错误,或者给我另一个解决方案/教程,让我在angular 8?中使用angular.json中的插件:

"scripts": [
          "./node_modules/jquery/dist/jquery.js",
          "./node_modules/popper.js/dist/umd/popper.js",
          "./node_modules/bootstrap/dist/js/bootstrap.js",
          "./node_modules/systemjs/dist/system.js"
        ]
以及进口:

import * as systemjs from 'systemjs';
而不是

declare const SystemJS: any;
您可以尝试使用:

const SystemJs: any = (window as any).System;

它在src/main.ts(12,27)中返回我错误:错误TS2307:找不到模块“systemjs”。是否安装了“systemjs”?使用
npm view systemjs version
进行检查,如果出现错误,请使用
npm install systemjs
进行安装。是的,我获得了版本4.1.0,然后尝试从“system”导入*as systemjs也许这有帮助