【发布时间】:2020-02-22 09:37:09
【问题描述】:
我知道类似的问题,例如 Angularjs 1.7.9 - Possibly unhandled rejection 以及其中提到的重复问题。
但是,我的代码不使用承诺(据我所知;当然没有 $promise 或 $http)。
我只是为朋友敲了一个简单的ui-router 演示。它只是两个视图,每个视图都有一个切换到另一个视图的按钮。它适用于 AngulrJs 1.5,并在 1.7 中打破上述错误。
虽然很简单,但要发布的代码太多了。以防万一,我不想在我的代码中找到错误,而是希望有一个规范的答案来帮助将来阅读此问题的其他人:如何消除此错误消息?
错误:转换失败(由“可能未处理的拒绝:{}”引起)
at r [as $get] (http://localhost/common/js/third_party/ui-router_zero_pint_2_point_11/angular-ui-router.min.js:7:11365) at Object.invoke (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:45:62) at http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:46:365 at d (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:43:495) at e (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:44:235) at Object.invoke (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:44:320) at http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:47:18 at r (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:8:76) at fb (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:46:499) at c (http://localhost/common/js/third_party/angular-1_point_7_point_9/angular.min.js:22:57)
【问题讨论】:
-
谢谢。关于不使用缩小的 AngaulrJs 的重要提示。我不知道“解析器”是什么,但谷歌会。再次感谢(点赞)
-
我会回复@wu-lee 对this question的回答
-
如果您禁用
$qProvider中的“未处理拒绝”错误,代码是否有效? -
它确实有效,只是给出了那些恼人的错误消息,出于明显的原因,我不希望全面压制。
-
如果您使用
angular.js而不是angular.min.js和angular-ui-router.js而不是angular-ui-router.min.js,您将获得更多信息的堆栈跟踪。 Angular-UI-Router 在它的转换模块中使用了 Promise。看起来您升级了 AngularJS 的版本而没有升级 Angular-UI-Router 的版本。将您的路由器从 V0.2.11 升级到 V0.4.3。看起来您的问题是由草率的 Angular-UI-Router 代码引起的。如果他们没有通过 V0.4.3 解决问题,您可以修补库或使用消息。
标签: angularjs debugging error-handling angular-ui-router angular-promise