angular 2如何使用web worker在后台运行进程?这样做我应该遵循什么模式?
我试过了:
npm i @angular/platform-webworker
npm i @angular/platform-webworker-dynamic
npm i @angular/platform-webworker
ng serve
进入app.module.ts我添加:
import {WorkerAppModule} from '@angular/platform-webworker';
//import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic';
//import {ServiceMessageBrokerFactory, PRIMITIVE} from '@angular/platform-webworker';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
WorkerAppModule,
HttpModule,
],
providers: [CommentService],
bootstrap: [AppComponent]
})
Angular 2正确编译,但在http://localhost:4200/我收到了这个错误:
zone.js:524 DOMException:无法执行' postMessage' on' Window':目标来源无效''在打电话给postMessage'。
我喜欢在背景中使用服务