【问题标题】:How to use ngrx-schematics in an Ionic 4 project?如何在 Ionic 4 项目中使用 ngrx-schematics?
【发布时间】:2019-06-07 18:09:12
【问题描述】:

我正在尝试在 Ionic 4 项目中使用 ngrx-schematics,但我似乎无法使其工作。

刚刚启动了一个 Ionic 4 项目并安装了 ngrx 商店、实体、效果和示意图。我也全局安装了 angular-cli 8,尽管 Ionic 仍然使用版本 7。我在网上找到了通过创建带有一些配置的 angular-cli.json 文件来使 ngrx-schematics 与 Ionic 3 一起工作的方法。我认为,从 Angular 6 开始,该文件不再存在于 Angular 项目中,所以我没有创建它。

我运行了命令ng config schematics.colection @ngrx/schematics,这样我就可以将角度原理图与ngrx原理图集成在一起。 不幸的是,它不起作用,因为当我尝试使用命令 ng g store State --root --module app.module.ts 创建商店时,出现以下错误:Error: Schematic "store" not found in collection "@ionic/angular-toolkit".

【问题讨论】:

    标签: angular ionic4 ngrx


    【解决方案1】:

    添加原理图的新方法(这里是ngrx/schematics)是ng config cli.defaultCollection @ngrx/schematics。这是reference

    【讨论】:

    • 添加 ngrx/schematics 后,ionic cli 因创建新页面而中断。我收到以下错误:集合“@ngrx/schematics”中找不到示意图“页面”。
    • 其实@ngrx/schematics默认扩展@schematics/angular。似乎一旦将其设置为默认值,您就只能使用与 angular 和 ngrx 相关的原理图。这是reference
    • 所以如果你想使用@ionic/angular-toolkit,你必须这样做ng g someCustomSchematics --collection someCustomCollection(这是用于角度的。只需将其更改为离子)。问题是,您需要将离子集合名称传递给它。有 PR 跟踪多个默认集合.. 看看。
    猜你喜欢
    • 1970-01-01
    • 2019-09-09
    • 2020-08-29
    • 2020-10-05
    • 2020-05-29
    • 2019-01-03
    • 2020-02-19
    • 2021-06-08
    • 1970-01-01
    相关资源
    最近更新 更多