1

我正在尝试使用自定义序列化程序来实现 ngx-router-store - 使用他们在此处的文档中显示的代码,但我收到以下错误:

ERROR in src/app/app.module.ts(58,13): error TS2345: Argument of type '{ serializer: typeof CustomSerializer; }' is not assignable to parameter of type 'StoreRouterConfig | StoreRouterConfigFunction'.
  Object literal may only specify known properties, and 'serializer' does not exist in type 'StoreRouterConfig | StoreRouterConfigFunction'.

app.module.ts

imports: [
    StoreModule.forRoot(reducers, { metaReducers }),
        RouterModule.forRoot([
            // routes
        ]),
        StoreRouterConnectingModule.forRoot({
            serializer: CustomSerializer,
        }),
        .......
       ]

减速器/index.ts

export const reducers: ActionReducerMap<AppState> = {
    router: routerReducer
};

我正在使用路由器商店版本 7.1.0:

在此处输入图像描述

StoreRouterConnectingModule.forRoot 中的配置对象接受的唯一属性是 stateKey。查看 StoreRouterConnectingModule 的 forRoot 方法,预期的类型是 StoreRouterConfig | 错误中详述的 StoreRouterConfigFunction。

我不确定我是否做错了什么,有些东西我没有实现,或者文档是否存在版本差异。

4

1 回答 1

1

您可以尝试清理node_modules文件夹并进行新安装吗?还要确保所有的 deps 都是 v7。

我刚刚尝试了文档中的配置,它在这里工作。

于 2019-01-28T19:23:48.197 回答