如何在 angular cli 6+ 中添加组件默认值 [英] How do I add component defaults in 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屋!