React-Select 官网首页渲染了一个 Dropdown,
https://react-select.com/home
需要调用原声的事件出发列表下拉,
React-Select 源码:
<Control
{...commonProps}
innerRef={this.getControlRef}
innerProps={{
**onMouseDown: this.onControlMouseDown,**
onTouchEnd: this.onControlTouchEnd,
}}
isDisabled={isDisabled}
isFocused={isFocused}
menuIsOpen={menuIsOpen}
>
但是现在不管在任何元素上面尝试
const event = new MouseEvent('mousedown', { view: window, cancelable: true, bubbles: true });
$0.dispatchEvent(event);
无法展开DropDown,请问是哪里出了错?
React
事件17以前是在document上做的事件委托,17以后是在react根节点