Angular2项目开发中所遇问题及解决方案记录(一)

发布时间:2019-06-03 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Angular2项目开发中所遇问题及解决方案记录(一)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_126_0@

Angular2项目开发中所遇问题及解决方案记录

最近在把一个Angularjs1.4版本的项目使用angular2框架进行升级,也把每天开发中遇到的问题及解放方案记录下来。

1、Webstorm can't find '@angular/core';

解决方案:

In webstorm : 
File->settings->Languages & Frameworks -> TypeScript ->enable typescript compiler & Use tsconfig.json

2、/localhost:3000/node_modules/RxJS.js 报错 404

Change your rxjs entry in package to this:

'rxjs': {
main: '/bundles/Rx.umd.js',
defaultExtension: 'js'
}    

3、of.js和From.js、fromPromise.js 找不到 报错404

仔细查看之后发现:rxjs-5.0.0-beta.11与rxjs-5.0.0-beta.2下面的observable包里的目录结构不一致。

4、在component中注入管道(pipe)时报错:can't find pipe~

Angular2项目开发中所遇问题及解决方案记录(一)


在stackoverflow中查到解决方案:
http://stackoverflow.com/questions/39539085/angular-2-0-release-pipes-and-directives-are-not-properties-of-component-anymo

Angular2项目开发中所遇问题及解决方案记录(一)

5、*ngFor指令不支持键值对结构?

解决方案:http://stackoverflow.com/questions/37046138/how-to-use-ngfor-with-object

6、No base href set. Please PRovide a value for the APP_BASE_HREF token or add a base element to the document.

解决方案: add <basehref='/'>

7、Error: Uncaught (in promise): Error: Cannot match any routes: ''"

解决方案:

Angular2项目开发中所遇问题及解决方案记录(一)

8、Can't bind to 'ngModel' since it isn't a known property of 'input'?

解决方案:In order to be able to use two-way data binding for form inputs you need to import theFormsModulepackage in your Angular module. For more info see the Angular 2 official tutorial here and the official documentation for forms

9、http post请求 response里面找不到headers?

解决方案:可以把map方法去了试试。

Angular2项目开发中所遇问题及解决方案记录(一)

ng2项目进行中,一步步的趟过去~

脚本宝典总结

以上是脚本宝典为你收集整理的Angular2项目开发中所遇问题及解决方案记录(一)全部内容,希望文章能够帮你解决Angular2项目开发中所遇问题及解决方案记录(一)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。