Angular 5升级RxJS到5.5.3报错:EmptyError: no elements in sequence
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。
注意:降版本时一定要把之前的卸载掉。