反应:应用悬停效果来反应引导NavDropdown元素

时间:2020-02-25 07:49:42

标签: css reactjs react-bootstrap

我试图在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 })
}

上面的代码不起作用。谁能告诉我我在想什么?

0 个答案:

没有答案