///这是我尝试从bundle.js导入组件但出现错误时的角度代码。
import { Component,AfterViewInit,OnInit } from '@angular/core';
import MyComponent from '../Component/bundle.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit,AfterViewInit{
title="App";
loadSettings = false;
ngOnInit(){
//this.myComponent.initialize();
}
ngAfterViewInit(){
MyComponent.initialize();
}
}
我有使用webpack创建的bundle.js,但是当我在我的angular4应用中导入该组件时,却出现了错误
Uncaught Error: Target container is not a DOM element. at invariant (invariant.js:42) at legacyRenderSubtreeIntoContainer (react-dom.development.js:17238) at render (react-dom.development.js:17317) at eval (index.js:18) at Object../examples/src/index.js (bundle.js:97) at __webpack_require__ (bundle.js:20) at bundle.js:84 at Object../src/Component/bundle.js (bundle.js:87) at __webpack_require__ (bootstrap:76) at Object../src/app/app.component.ts (main.js:524)