【问题标题】:Angular 6 mysterious stacktrace: globalZoneAwareCallbackAngular 6 神秘的堆栈跟踪:globalZoneAwareCallback
【发布时间】:2019-03-12 16:29:08
【问题描述】:

最近,使用 Angular6,我开始在浏览器控制台中观察到描述性极差的堆栈跟踪:

错误错误:“[object Object]”
resolvePromise
http://localhost:8080/polyfills.js:3136:31resolvePromise
http://localhost:8080/polyfills.js:3093:17scheduleResolveOrReject
http://localhost:8080/polyfills.js:3195:17invokeTask
http://localhost:8080/polyfills.js:2743:17onInvokeTask
http://localhost:8080/vendor.js:36899:24invokeTask
http://localhost:8080/polyfills.js:2742:17runTask
http://localhost:8080/polyfills.js:2510:28drainMicroTask
http://localhost:8080/polyfills.js:2917:25invokeTask
http://localhost:8080/polyfills.js:2822:21invokeTask
http://localhost:8080/polyfills.js:3862:9globalZoneAwareCallback
http://localhost:8080/polyfills.js:3888:17core.js:1673
默认错误记录器
core.js:1673
./node_modules/@angular/core/fesm5/core.js
/ErrorHandler.prototype.handleError
core.js:1719
下一个
core.js:4319:109
./node_modules/@angular/core/fesm5/core.js
/EventEmitter.prototype.subscribe/schedulerFn core.js:3555:34
./node_modules/rxjs/_esm5/internal/Subscriber.js
/SafeSubscriber.prototype.__tryOrUnsub
订阅者.js:195
./node_modules/rxjs/_esm5/internal/Subscriber.js
/SafeSubscriber.prototype.next
订阅者.js:133
./node_modules/rxjs/_esm5/internal/Subscriber.js
/Subscriber.prototype._next
订阅者.js:77
./node_modules/rxjs/_esm5/internal/Subscriber.js
/Subscriber.prototype.next
订阅者.js:54
./node_modules/rxjs/_esm5/internal/Subject.js/Subject.prototype.next
Subject.js:47
./node_modules/@angular/core/fesm5/core.js/EventEmitter.prototype.emit
core.js:3539:52
onHandleError/ core.js:3846:48
./node_modules/zone.js/dist/zone.js/ zone.js:388
./node_modules/zone.js/dist/zone.js/ zone.js:138
./node_modules/@angular/core/fesm5/core.js
/NgZone.prototype.runOutsideAngular
core.js:3783
onHandleError
core.js:3846
./node_modules/zone.js/dist/zone.js
/ zone.js:392
./node_modules/zone.js/dist/zone.js/ zone.js:154
_loop_1
zone.js:677
./node_modules/zone.js/dist/zone.js/ zone.js:686
drainMicroTaskQueue
zone.js:602
./node_modules/zone.js/dist/zone.js/ zone.js:500
调用任务
zone.js:1540
globalZoneAwareCallback
zone.js:1566

我怀疑路由模块中有一些错误,所以我正在粘贴我的配置:

const routes = [
  {
    path: 'wordspreview/:id',
    component: WordsPreviewComponent
  },
  {
    path: 'wordspreview',
    component: WordsPreviewComponent
  },
  {
    path: 'search/:query',
    component: SearchResultsComponent
  },
  {
    path: '',
    redirectTo: '/wordspreview',
    pathMatch: 'full'
  }
};

希望有人能提供帮助。

【问题讨论】:

    标签: javascript angular6 angular-router


    【解决方案1】:

    我只是自己发现了这个错误。

    无法在其他任何地方搜索它,我将在此处留下解决方案以帮助下一个潜在的受害者:

    constructor(private router : Router,
    [...]
    this.router.navigate([site, id]);
    

    我做错的是导航到错误的site。调试起来很困难,因为它只出现在一些罕见的错误site 值中。

    【讨论】:

      猜你喜欢
      • 2017-07-16
      • 1970-01-01
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      • 2011-05-25
      • 2011-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多