具有 hiderBackdrop 参数的 Popover 的 onMouseLeave(材质 ui)

And*_*ich 1 html css reactjs material-ui

   <Popover
       key={element.name}
       className={classes.popover}
       classes={{
         paper: classes.paper
       }}
       open={open}
       anchorEl={this.myRef.current}
       anchorOrigin={{
         vertical: 'bottom',
         horizontal: 'left'
       }}
       transformOrigin={{
         vertical: 'top',
         horizontal: 'left'
       }}
       disableRestoreFocus
       hideBackdrop
    >
Run Code Online (Sandbox Code Playgroud)

我有这种弹出窗口,我想执行onMouseLeave事件,但它不起作用。我该如何解决它?发生这种情况是因为我认为该元素中没有其他 html 元素,这就是它不发出任何操作的原因。也许存在解决这个问题的方法?

这是文档上的链接 - https://material-ui.com/utils/popover/

小智 5

尝试将 onMouseLeave 设置为 PaperProps={{onMouseLeave: onClose}}

  • 所有事件都发布在这里:https://reactjs.org/docs/handling-events.html 其直接的内容。 (2认同)