angular2后台管理系统
2022-08-03 09:57:03
245
{{single.collect_count}}

angular2-4对angular1的改变是颠覆性的,增加了npm, typescript,@等目前前端开发流行的元素,但坑多

github上开源项目:https://github.com/mrholek/CoreUI-Free-Bootstrap-Admin-Template/tree/master/Angular2_CLI_Full_Project
这是基于angular2的后台管理系统

执行npm start时webpack:compiled successfully,但运行时报错,如下:

EXCEPTION: Uncaught (in promise): Error: Cannot find module './dashboard/dashboard.module'.Error: Cannot find module './dashboard/dashboard.module'.at ZoneAwareError (http://localhost:4200/polyfills.bundle.js:6361:33)at webpackAsyncContext (http://localhost:4200/main.bundle.js:35:25)at SystemJsNgModuleLoader.webpackJsonp.../../../../_@angular_core@2.4.9@@angular/core/src/linker/system_js_ng_module_factory_loader.js.SystemJsNgModuleLoader.loadAndCompile 

显然是路由ts文件中报错,但设置是对的。
将路由文件代码中./改为app/就可以,原因是angular-cli版本过低,解决方法调高angular-cli版本。

改了后,npm start,编译报错,如下:

Searching for devices...iTunes is not available for this operating system. You will not be able to work with connected iOS devices.Executing before-prepare hook from /home/dhrn/NativeApp/Supervisor/hooks/before-prepare/nativescript-dev-typescript.jsFound peer TypeScript 2.4.1node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.Types of property 'lift' are incompatible.Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.Type 'Observable<T>' is not assignable to type 'Observable<R>'.Type 'T' is not assignable to type 'R'.

原因是package.json中typescript与rxjs版本冲突,可以在tsconfig.json中增加:”noStrictGenericChecks”: true,如下:

{"compilerOptions": {"baseUrl": "","declaration": false,"emitDecoratorMetadata": true,"noStrictGenericChecks": true,"experimentalDecorators": true,"lib": ["es2016","dom"],"mapRoot": "./","module": "es2016","moduleResolution": "node","outDir": "../dist/out-tsc","sourceMap": true,"target": "es5","typeRoots": ["../node_modules/@types"]}}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}