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

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

问题描述

在旧的角度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"
    }
  }

此属性不再存在.如何在角度cli 6+中推送时添加component/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:

"projects": { "my-project": { "root": "", "sourceRoot": "src", "projectType": "application", "prefix": "app", "schematics": { "@schematics/angular:component": { "changeDetection": "OnPush" } },

"projects": { "my-project": { "root": "", "sourceRoot": "src", "projectType": "application", "prefix": "app", "schematics": { "@schematics/angular:component": { "changeDetection": "OnPush" } },

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

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