欢迎来到代码驿站!

AngularJS

当前位置:首页 > 网页前端 > AngularJS

Angular5升级RxJS到5.5.3报错:EmptyError: no elements in sequence的解决方法

时间:2021-03-12 09:55:22|栏目:AngularJS|点击:

前言

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。

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

总结

上一篇:AngularJS中下拉框的高级用法示例

栏    目:AngularJS

下一篇:详解Angular4中路由Router类的跳转navigate

本文标题:Angular5升级RxJS到5.5.3报错:EmptyError: no elements in sequence的解决方法

本文地址:http://www.codeinn.net/misctech/79291.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有