简体   繁体   English

Angular 原理图跳过“实现 OnInit”

[英]Angular Schematics Skip "implements OnInit"

I've found plenty about how to setup my schematic file to skip certain things (like the spec file) when creating a component using ng generate but what I can't find anywhere is how to not include the implements OnInit when I use ng generate component .我发现了很多关于如何设置我的原理图文件以在使用ng generate创建组件时跳过某些东西(比如 spec 文件)但是我在任何地方都找不到的是如何在我使用ng generate component时不包含implements OnInit ng generate component

I've looked everwhere.我到处都看过。 Anyone have an idea?有人有想法吗?

到今天为止,还没有这个选项

There is no official way to do this, but there is a trick that allows you to generate new components without implements OnInit or Constructor() .没有正式的方法可以做到这一点,但有一个技巧可以让您在不implements OnInitConstructor()的情况下生成新组件。

You just have to mismatch the node version.您只需要使节点版本不匹配即可。 The Constructor and implements OnInit is not generated when using node 16.17.0 with Angular v15 in Windows, but it works fine in Linux Ubuntu. So you'll have to figure it out for yourself by changing only the minor version of the node.在 Windows 中将节点 16.17.0 与 Angular v15 一起使用时,不会生成Constructorimplements OnInit ,但它在 Linux Ubuntu 中运行良好。因此,您必须通过仅更改节点的次要版本来自行解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM