【问题标题】:What type does the event passed to the listener for the IE 11 specific deactivate event have?传递给 IE 11 特定 deactivate 事件的侦听器的事件有什么类型?
【发布时间】:2019-03-18 21:35:48
【问题描述】:

这是我的代码中的常见事件。我知道调用 onChange 事件的类型。

private onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    ...
};

但是传递给这个事件监听器的事件是什么类型的呢?

// Since blur is asynchronous in IE11 we can't guarantee that a change
// will be saved onBlur when changing component model. The IE exclusive
// `deactivate` event triggers before any other click handlers.

this.inputRef.current!.addEventListener('deactivate', this.onDeactivate);

private onDeactivate = (e: any) => {
    ...
};

【问题讨论】:

    标签: typescript internet-explorer-11


    【解决方案1】:

    this.inputRef.current!.addEventListener('deactivate', this.onDeactivate); 中,如果currentHTMLInputElement 类型,那么eEvent 类型。

    如何解决

    添加一个本地函数并将鼠标悬停在参数上以查看其推断类型。

    这里是 react onChange 的类型(你已经知道了):

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-07
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多