我正在尝试仅在悬停到特殊div时显示一些信息。我使用material ui和他们的withStyles组件。有没有办法做到这一点?
发布于 2020-04-17 00:08:10
请检查此示例:
import React, {useState} from "react";
export default function ShowButtonHover() {
const [style, setStyle] = useState({display: 'none'});
return (
<div className="App">
<h2>Hidden message in the box. Move mouse in the box</h2>
<div style={{border: '1px solid gray', width: 300, height: 300, padding: 10, margin: 100}}
onMouseEnter={e => {
setStyle({display: 'block'});
}}
onMouseLeave={e => {
setStyle({display: 'none'})
}}
>
<div style={style}>This was hidden</div>
</div>
</div>
);
}https://stackoverflow.com/questions/61254717
复制相似问题