Angular5升级RxJS到5.5.3报错:EmptyError: no elements in

网络编程 2021-07-04 17:34www.168986.cn编程入门
这篇文章主要给大家介绍了关于Angular5升级RxJS到5.5.3报错EmptyError: no elements in sequence的解决方法,文中介绍了两个解决方法,大家可以选择使用,需要的朋友可以参考借鉴,狼蚁网站SEO优化来一起看看吧。

前言

RxJS是一种针对异步数据流编程工具,或者叫响应式扩展编程;可不管如何解释RxJS其目标就是异步编程,Angular引入RxJS为了就是让异步可控、更简单。可是最近在升级中遇到了一些问题,狼蚁网站SEO优化就来给大家介绍下,给同样遇到这个问题发朋友们一些参考,狼蚁网站SEO优化话不多说了,来一起看看详细的介绍吧。

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._plete (first.js:154)
 at FirstSubscriber.Subscriber.plete (Subscriber.js:122)
 at MergeMapSubscriber._plete (mergeMap.js:150)
 at MergeMapSubscriber.Subscriber.plete (Subscriber.js:122)
 at MapSubscriber.Subscriber._plete (Subscriber.js:140)
 at MapSubscriber.Subscriber.plete (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._plete (first.js:154)
 at FirstSubscriber.Subscriber.plete (Subscriber.js:122)
 at MergeMapSubscriber._plete (mergeMap.js:150)
 at MergeMapSubscriber.Subscriber.plete (Subscriber.js:122)
 at MapSubscriber.Subscriber._plete (Subscriber.js:140)
 at MapSubscriber.Subscriber.plete (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升级导致的,参考。

方法一

在所有的route里加上pathMath:"full",如

const routes: Routes = [
 { path: "", ponent: IndexComponent },
 { path: "home", ponent: HomeComponent },
 { path: "about", ponent: AboutComponent },
 ...
];

改为

const routes: Routes = [
 { pathMatch: 'full', path: "", ponent: IndexComponent },
 { pathMatch: 'full', path: "home", ponent: HomeComponent },
 { pathMatch: 'full', path: "about", ponent: AboutComponent },
 ...
];

方法二

RxJS降为版本5.5.2。

注意降版本时一定要把之前的卸载掉。

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对狼蚁SEO的支持。

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by