2

我正在尝试创建一个 Angular 4 plunker,其中包括 ngrx\store 最新版本: https ://embed.plnkr.co/cr4rCJ0hRVMwuLzKe4mg/

为了使用 ngrx\store 我在config.js文件中添加了这一行:

'@ngrx/store': 'https://npmcdn.com/@ngrx/store@4.0.0',

出于某种原因,我收到此错误:

(SystemJS) TypeError: store_1.StoreModule.provideStore is not a function

有人可以帮忙吗?

4

2 回答 2

4

在最新版本的 Ngrx 中,provideStore更改为forRoot.

您也可以在这里查看迁移指南https://github.com/ngrx/platform/blob/master/MIGRATION.md

于 2017-08-04T10:25:38.840 回答
0

您应该在 Angular 6 等最新版本的 Angular 中将“provideStore”更改为“forRoot”。它对我有用。

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule} from '@angular/forms';
import { UsersServiceService } from './users/users-service.service';
import { PDFGenerationService } from './pdf-generation-demo/pdf-generation.service';
import { AppRoutingModule, routingComponents } from './app-routing.module';
// Import ng-circle-progress
import { NgCircleProgressModule } from 'ng-circle-progress';
import { mainStoreReducer } from './state/reducers/reducer';
import { StoreModule } from '@ngrx/store';


@NgModule({
  declarations: [
    AppComponent,
    routingComponents
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    AppRoutingModule,
    NgCircleProgressModule.forRoot({
      // set defaults here
      radius: 100,
      outerStrokeWidth: 16,
      innerStrokeWidth: 8,
      outerStrokeColor: "#78C000",
      innerStrokeColor: "#C7E596",
      animationDuration: 300
    }),
    StoreModule.forRoot({ mainStoreReducer })
  ],
  exports: [   ],
  providers: [UsersServiceService, PDFGenerationService],
  bootstrap: [AppComponent]
})

export class AppModule { }
于 2018-10-10T10:48:44.023 回答