如何在 angular cli 6+ 中添加组件默认值 [英] How do I add component defaults in angular cli 6+

查看:29
本文介绍了如何在 angular cli 6+ 中添加组件默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧的 angular cli 中有一个名为 defaults 的键:

In the old angular cli there was a key called defaults:

"defaults": {
    "schematics": {
      "collection": "@nrwl/schematics",
      "postGenerate": "npm run format",
      "newProject": [
        "app",
        "lib"
      ]
    },
    "styleExt": "scss",
    "component": {
      "changeDetection": "OnPush"
    }
  }

此属性不再存在.如何在 angular cli 6+ 中添加组件/changeDetection?此外,是否有我可以添加的组件属性列表?

This property no longer exsists. How do I add component/changeDetection on push in angular cli 6+? moreover is there a list of component properties I can add?

推荐答案

我对旧的 CLI 不太熟悉.这些属性是配置为全局 CLI 设置还是每个项目的设置?

I'm not as familiar with the old CLI. Were those properties configured as global CLI settings, or a per-project setting?

在新的 Angular CLI 中,您可以通过将 schematics 对象更新为以下内容来复制 angular.json 文件中的每个项目设置:

In the new Angular CLI, you can replicate per-project settings in the angular.json file by updating the schematics object to the following:

<代码>项目":{我的项目": {根": "","sourceRoot": "src","projectType": "应用程序",前缀":应用程序",示意图":{@schematics/angular:component":{"changeDetection": "OnPush"}},

这篇关于如何在 angular cli 6+ 中添加组件默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆