xwt
2 天以前 0d3eadb50310ca60b8871e967e64da01aa25a9ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
declare namespace UniNamespace {
  interface OnUnhandledRejectionCallbackResult {
    /**
     * 被拒绝的 Promise 对象
     */
    promise: Promise<any>;
    /**
     * 拒绝原因,一般是一个 Error 对象
     */
    reason: string;
  }
 
  /**
   * 未处理的 Promise 拒绝事件的回调函数
   */
  type OnUnhandledRejectionCallback = (result: OnUnhandledRejectionCallbackResult) => void;
}
 
interface Uni {
  /**
   * 监听未处理的 Promise 拒绝事件。该事件与 `App.onUnhandledRejection` 的回调时机与参数一致。
   *
   * **注意**
   *
   *
   * - 安卓平台暂时不支持该事件
   * - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。
   *
   * 最低基础库: `2.10.0`
   *
   * 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html)
   */
  onUnhandledRejection(callback: UniNamespace.OnUnhandledRejectionCallback): void;
 
  /**
   * 取消监听未处理的 Promise 拒绝事件
   *
   * 最低基础库: `2.10.0`
   *
   * 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html)
   */
  offUnhandledRejection(callback: UniNamespace.OnUnhandledRejectionCallback): void;
}