加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

ErrorHandler中的Angular 2路径error.stack

发布时间:2020-12-17 17:10:06 所属栏目:安全 来源:网络整理
导读:我正在尝试使用stacktrace.js来报告错误,但堆栈跟踪中的路径引用了“ng:///FormModule/MyComponent.ngfactory.js” TypeError: Cannot read property 'push' of undefined at Object.eval [as handleEvent] (ng:///FormModule/MyComponent.ngfactory.js:668
我正在尝试使用stacktrace.js来报告错误,但堆栈跟踪中的路径引用了“ng:///FormModule/MyComponent.ngfactory.js”

TypeError: Cannot read property 'push' of undefined
    at Object.eval [as handleEvent] (ng:///FormModule/MyComponent.ngfactory.js:668:41)
    at handleEvent (http://localhost/dist/form/angular-vendor.bundle.js:12204:138)
    at callWithDebugContext (http://localhost/dist/form/angular-vendor.bundle.js:13665:42)
    at Object.debugHandleEvent [as handleEvent] (http://localhost/dist/form/angular-vendor.bundle.js:13253:12)
    at dispatchEvent (http://localhost/dist/form/angular-vendor.bundle.js:8808:21)
    at http://localhost/dist/form/angular-vendor.bundle.js:9419:20
    at HTMLAnchorElement.<anonymous> (http://localhost/dist/form/angular-vendor.bundle.js:29309:53)
    at ZoneDelegate.invokeTask (http://localhost/dist/form/polyfills.bundle.js:7779:31)
    at Object.onInvokeTask (http://localhost/dist/form/angular-vendor.bundle.js:4090:33)
    at ZoneDelegate.invokeTask (http://localhost/dist/form/polyfills.bundle.js:7778:36)
    at Zone.runTask (http://localhost/dist/form/polyfills.bundle.js:7546:47)
    at HTMLAnchorElement.ZoneTask.invoke (http://localhost/dist/form/polyfills.bundle.js:7841:38)

Stacktrace.js找不到捆绑文件及其对应的源映射,因为无法加载此路径

XMLHttpRequest cannot load ng:///FormModule/MyComponent.ngfactory.js. Cross origin requests are only supported for protocol schemes: http,data,chrome,chrome-extension,https.

是否有人使用WebPack,Stacktrace.js并使源地图工作,或者有人知道如何解决这个问题吗?

解决方法

通过将{offline:true}作为第二个参数传递给StackTrace.fromError方法,修复了Angular 6项目中的类似问题,如下所示:

StackTrace.fromError(error,{offline: true}).then(...

正如建议here.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读