Dom 将事件侦听器添加到窗口

Dom 将事件侦听器添加到窗口,dom,reason,bs-webapi,Dom,Reason,Bs Webapi,我正在尝试向窗口添加事件侦听器,但不确定如何获取窗口 我现在有这个 let onUnhandledRejection = (e) => { /* TODO: write this */ } WindowRe.addEventListener( "unhandledrejection", onUnhandledRejection, WINDOW_GOES_HERE: Dom.window ); 当前窗口对象可用作Webapi.Dom.window let onUnhand

我正在尝试向窗口添加事件侦听器,但不确定如何获取窗口

我现在有这个

let onUnhandledRejection = (e) => {
  /* TODO: write this */
}

WindowRe.addEventListener(
  "unhandledrejection",
  onUnhandledRejection,
  WINDOW_GOES_HERE: Dom.window
);

当前窗口对象可用作
Webapi.Dom.window

let onUnhandledRejection = (e) => {
  /* TODO: write this */
}

Webapi.Dom.Window.addEventListener(
  "unhandledrejection",
  onUnhandledRejection,
  Webapi.Dom.window
);

您也不应该使用
WindowRe
,因为它是一个私有API。

这就解释了:
window
对象?它在全局范围内。请注意,
Dom
(前面没有
Webapi.
)是一个随
bs平台
附带的模块,其中包含
Webapi
使用的大多数类型。这可能有点让人困惑,但我们希望将来在命名方面会更聪明一些。