Angular2項目日常開發(fā)中所遇問題及解決方案記錄(一)

最近在把一個angularjs1.4版本的項目使用angular2框架進(jìn)行升級,因此也把個人每天開發(fā)中遇到的問題及解放方案記錄下來,不定時更新~

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

仔細(xì)查看之后發(fā)現(xiàn):rxjs-5.0.0-beta.11與rxjs-5.0.0-beta.2下面的observable包里的目錄結(jié)構(gòu)不一致。

4、在Component中注入管道(pipe)時報錯:can't find pipe~


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

5、*ngFor指令不支持鍵值對結(jié)構(gòu)?

解決方案: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: ''"

解決方案:

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方法去了試試。


ng2項目進(jìn)行中,一步步的趟過去~

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容