微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angular2后台管理系统

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.js
Found peer TypeScript 2.4.1
node_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" ] } }

原文地址:https://www.jb51.cc/angularjs/146264.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐