這次帶給大家怎麼解決Angular5升級RxJS到5.5.3報錯問題,解決Angular5升級RxJS到5.5.3報錯的注意事項有哪些,下面就是實戰案例,一起來看一下。
前言
RxJS是一種針對非同步資料流程式設計工具,或稱為響應式擴充程式設計;可不管如何解釋RxJS其目標就是非同步編程,Angular引入RxJS為了就是讓非同步可控、更簡單。可是最近在升級中遇到了一些問題,以下就來給大家介紹下,給同樣遇到這個問題發朋友們一些參考,下面話不多說了,來一起看看詳細的介紹吧。
Angular 5.0.5升級RxJS到5.5.3報錯:
ERROR Error: Uncaught (in promise): EmptyError: no elements in sequence EmptyError: no elements in sequence at new EmptyError (EmptyError.js:28) at FirstSubscriber._complete (first.js:154) at FirstSubscriber.Subscriber.complete (Subscriber.js:122) at MergeMapSubscriber._complete (mergeMap.js:150) at MergeMapSubscriber.Subscriber.complete (Subscriber.js:122) at MapSubscriber.Subscriber._complete (Subscriber.js:140) at MapSubscriber.Subscriber.complete (Subscriber.js:122) at EmptyObservable._subscribe (EmptyObservable.js:83) at EmptyObservable.Observable._trySubscribe (Observable.js:172) at EmptyObservable.Observable.subscribe (Observable.js:160) at new EmptyError (EmptyError.js:28) at FirstSubscriber._complete (first.js:154) at FirstSubscriber.Subscriber.complete (Subscriber.js:122) at MergeMapSubscriber._complete (mergeMap.js:150) at MergeMapSubscriber.Subscriber.complete (Subscriber.js:122) at MapSubscriber.Subscriber._complete (Subscriber.js:140) at MapSubscriber.Subscriber.complete (Subscriber.js:122) at EmptyObservable._subscribe (EmptyObservable.js:83) at EmptyObservable.Observable._trySubscribe (Observable.js:172) at EmptyObservable.Observable.subscribe (Observable.js:160) at resolvePromise (zone.js:824)
這應該是RxJS升級導致的,參考issue。
方法一
在所有的route裡加上pathMath:"full",如
const routes: Routes = [ { path: "", component: IndexComponent }, { path: "home", component: HomeComponent }, { path: "about", component: AboutComponent }, ... ];
改為
const routes: Routes = [ { pathMatch: 'full', path: "", component: IndexComponent }, { pathMatch: 'full', path: "home", component: HomeComponent }, { pathMatch: 'full', path: "about", component: AboutComponent }, ... ];
方法二
RxJS降為版本5.5.2。
注意:降版本時一定要把先前的卸載掉。
相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!
推薦閱讀:
以上是怎麼解決Angular5升級RxJS到5.5.3報錯問題的詳細內容。更多資訊請關注PHP中文網其他相關文章!