angular入门成本很高,原因是坑人的配置太多,而且官网也没有说的很明白,导致一些问题要花很多时间来解决。
1.查看angular版本,在package.json中查看:下面这个是4.3的版本
"@angular/animations": "^4.3.0", "@angular/common": "^4.3.0", "@angular/compiler": "^4.3.0", "@angular/core": "^4.3.0", "@angular/forms": "^4.3.0", "@angular/http": "^4.3.0", "@angular/platform-browser": "^4.3.0", "@angular/platform-browser-dynamic": "^4.3.0", "@angular/router": "^4.3.0",
2.system.config.js文件,这个文件加载了一些新手看不懂的东西,但是这个文件不注意,你很可能花上几天解决出的问题,文件中都是导入包时一些依赖项。【如果你导入一些东西一直报错,当然这个错在写代码时是看不出来的,都在浏览器里报错,很可能是你原始的system.config.js根本就没加这个东西,比如:'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js'这个包,是angular 4.3新特性】。
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js', '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js', '@angular/core': 'npm:@angular/core/bundles/core.umd.js', '@angular/common': 'npm:@angular/common/bundles/common.umd.js', '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', '@angular/http': 'npm:@angular/http/bundles/http.umd.js', '@angular/router': 'npm:@angular/router/bundles/router.umd.js', '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js', '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
3.子module,如果你分离了app.module.ts 文件,请注意,一些需要import的模块,一定一定要在子module里在注册一次,要不永远找不到。。。
like this:
我会不断总结开发中遇到的坑。