在图像上方添加文字,并在React Native中使用OnMouseenter
当鼠标悬停在图像上方时,我想在图像上方有文本。我尝试了一些事情,但是OnMouseenter/Onmouseleave似乎是最有前途的。我遇到了一个错误: 当我徘徊在图像上时,我的文字不在这里。这是我的代码:
<View
style={{
flex: 1,
justifyContent: "center",
}}
>
<div
onMouseEnter={() => {
<Text>Hi here</Text>;
}}
onMouseLeave={() => {}}
>
<Image
source={screen2}
style={{
width: "80%",
height: "80%",
marginBottom: 150,
marginTop: 120,
marginLeft: "-10%",
}}
/>
</div>
</View>
I want to have text apear above my image when my mouse hover over it. I tryed some things, but the onMouseEnter/onMouseLeave seems the most promising. Howether I encountered an error:
When I hover over my image, my text is not here. Here is my code :
<View
style={{
flex: 1,
justifyContent: "center",
}}
>
<div
onMouseEnter={() => {
<Text>Hi here</Text>;
}}
onMouseLeave={() => {}}
>
<Image
source={screen2}
style={{
width: "80%",
height: "80%",
marginBottom: 150,
marginTop: 120,
marginLeft: "-10%",
}}
/>
</div>
</View>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用钩子设置图像显示,当鼠标输入时,您将钩子设置为true时,当鼠标留下您设置为false时
You can use an hook to set the image show, when the mouse enter you set your hook for true when the mouse leave you set to false