我试图采用现有的 ngrx 存储状态并将其重构为子功能模块。问题是当我在我的功能模块导入中使用 StoreModule.forFeature 时......我在编译过程中出现错误:
ERROR in [at-loader] ./src/app/components/login/login.module.ts:67:21
TS2339: Property 'forFeature' does not exist on type 'typeof StoreModule'.
我实际上已经在 node_modules/@ngrx/store 中搜索了“forFeature”,但没有产生任何结果。然后我重新安装了@ngrx/store 和@ngrx/core,仍然没有得到“forFeature”的搜索结果。我检查了文档,“forFeature”仍然在文档列表中列出,而不是被弃用。
导入语句如下:
import {StoreModule} from "@ngrx/store";
import {reducers} from "./rdx/reducers/index"; ...
@NgModule({
imports: [StoreModule.forFeature('loginFeature',reducers)]
...
}
使用 o NGRX 的版本,如包 json 所示,如下所示:
"@ngrx/core": "^1.2.0",
"@ngrx/store": "^2.2.3",
还用谷歌搜索了这个问题,没有结果。只有将“forRoot”改为“provideStore”的结果,我已经使用了。