我试图在reactjs中将悬浮效果应用于NavDropdown, 我尝试了以下方法。
<NavDropdown title="Dropdown" onMouseEnter={ this.handleOpen } onMouseLeave={ this.handleClose } open={ this.state.isOpen } id="basic-nav-dropdown">
<NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
<NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
</NavDropdown>
constructor(props) {
super(props)
this.state = { isOpen: false }
}
handleOpen = () => {
this.setState({ isOpen: true })
}
handleClose = () => {
this.setState({ isOpen: false })
}
上面的代码不起作用。谁能告诉我我在想什么?