ng-alain使用中的路由部分自动代码生成的一个问题

在ng-alain8.5.0的使用中,发现使用ng g ng-alain:list list -m=模块名称命令时多次出现路由部分的代码多生成一个分号的问题,使用本文予以memo,问题很小,无伤大雅,估计后续版本会更正此问题。

版本

ng-alain :8.5.0

liumiaocn:ui liumiao$ grep ng-alain package.json 
    "icon": "ng g ng-alain:plugin icon"
    "ng-alain": "^8.5.0",
    "ng-alain-codelyzer": "^0.0.1"
liumiaocn:ui liumiao$ 
liumiaocn:routes liumiao$ npm -v
6.4.1
liumiaocn:routes liumiao$ node -v
v10.15.3
liumiaocn:routes liumiao$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.9
Node: 10.15.3
OS: darwin x64
Angular: 8.2.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.9
@angular-devkit/build-angular     0.803.9
@angular-devkit/build-optimizer   0.803.9
@angular-devkit/build-webpack     0.803.9
@angular-devkit/core              8.3.9
@angular-devkit/schematics        8.3.9
@angular/cdk                      8.2.3
@angular/cli                      8.3.9
@ngtools/webpack                  8.3.9
@schematics/angular               8.3.9
@schematics/update                0.803.9
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2
    
liumiaocn:routes liumiao$

现象说明

webpack运行中的页面发现之前菜单中运行OK的路由出现“无法加载xxx/xxx路由”

问题重现

生成list页面

liumiaocn:routes liumiao$ ng g ng-alain:list list -m=model
CREATE src/app/routes/model/list/list.component.html (352 bytes)
CREATE src/app/routes/model/list/list.component.spec.ts (643 bytes)
CREATE src/app/routes/model/list/list.component.ts (1264 bytes)
UPDATE src/app/routes/model/model.module.ts (1008 bytes)
UPDATE src/app/routes/model/model-routing.module.ts (615 bytes)
liumiaocn:routes liumiao$

修改内容确认

可以看到自动代码添加的部分多了一个分号。
在这里插入图片描述

发生频度

偶发型问题,目前不知满足和条件会发生

确认方法

typescript的lint代码检查可以提前意识到问题,因为ng-alain使用了husky进行集成,在代码提交时也会无法通过。

liumiaocn:ui liumiao$ npm run lint:ts

> [email protected] lint:ts /Users/liumiao/Desktop/glaucus/ui
> tslint -p tsconfig.app.json -c tslint.json "src/**/*.ts" --fix


ERROR: /Users/liumiao/Desktop/glaucus/ui/src/app/routes/model/model-routing.module.ts:9:53 - Array has a missing element.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint:ts: `tslint -p tsconfig.app.json -c tslint.json "src/**/*.ts" --fix`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] lint:ts script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
liumiaocn:ui liumiao$ 

你可能感兴趣的:(#,Angular快速入门)