Ionic Angular自动捕获错误 配置Angular2.x +
生活随笔
收集整理的這篇文章主要介紹了
Ionic Angular自动捕获错误 配置Angular2.x +
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
配置app.module.ts
import { Pro } from '@ionic/pro';// These are the imports required for the code below, // feel free to merge into existing imports. import { Injectable, Injector } from '@angular/core'; import { IonicErrorHandler } from 'ionic-angular';const IonicPro = Pro.init('APP_ID', {appVersion: "APP_VERSION" });@Injectable() export class MyErrorHandler implements ErrorHandler {ionicErrorHandler: IonicErrorHandler;constructor(injector: Injector) {try {this.ionicErrorHandler = injector.get(IonicErrorHandler);} catch(e) {// Unable to get the IonicErrorHandler provider, ensure // IonicErrorHandler has been added to the providers list below}}handleError(err: any): void {IonicPro.monitoring.handleNewError(err);// Remove this if you want to disable Ionic's auto exception handling// in development mode.this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);} }?
//將此條目添加到providersin NgModule
providers: [// ..., IonicErrorHandler,[{ provide: ErrorHandler, useClass: MyErrorHandler }] // <<===]?
eg:https://ionicframework.com/docs/pro/monitoring/
轉載于:https://www.cnblogs.com/Rampage/p/8117702.html
總結
以上是生活随笔為你收集整理的Ionic Angular自动捕获错误 配置Angular2.x +的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sql根据类别拆分上下级_运用SQL对黑
- 下一篇: MATLAB矩阵操作和算术运算符