【发布时间】:2018-04-21 06:17:56
【问题描述】:
我有这种情况https://jsfiddle.net/ffq1p77m/ 实际上将链接悬停在一个框显示相关内容但它显示在 UL 内的一个框中,我会将内容放在 ul 之外的另一个 div 中,这可能吗?
class Item extends React.Component {
constructor(props) {
super(props);
this.state = {
isHovered: false,
};
}
handleEnter() {
this.setState({
isHovered: true
});
}
handleLeave() {
this.setState({
isHovered: false
});
}
render() {
return <div><li><a href="#" onMouseEnter={this.handleEnter.bind(this)}
onMouseLeave={this.handleLeave.bind(this)}>
{ this.props.name }</a>
{ this.props.children }</li>{this.state.isHovered ? (
<div className="box">{this.props.content}</div>
) : (
<div />
)}</div>
}
}
【问题讨论】:
标签: javascript reactjs javascript-framework react-props