如何在React中的对象中使用悬停
我定义了一个对象USESTYLE
,并在组件secondtest
定义的背景颜色中调用它,是否可以在对象USESTYLE
中添加悬停
const useStyle = {
backgroundColor: "red",
};
function SecondTest() {
return <div style={useStyle}>SecondTest go down</div>;
}
export default SecondTest;
I defined a object useStyle
and called it in the component SecondTest
defined background color, is it possible to add hover in the object useStyle
const useStyle = {
backgroundColor: "red",
};
function SecondTest() {
return <div style={useStyle}>SecondTest go down</div>;
}
export default SecondTest;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用Radium React库
You can use Radium React Library
您可以通过
onMouseEnter
&amp;OnMouseLeave
如果您想使用JavaScript解决您的问题。更轻松的方法将只是给出一个元素className
像&lt; section className ='myclass'&gt; hello world&lt;/section&gt;
,然后只是添加所需的所需.CSS文件中的属性,您可以在组件中或全球导入。
不可能通过在线样式添加悬停。
You can accomplish it with events like
onMouseEnter
&onMouseLeave
if you wish to use javascript to solve your issue. Easier way to do it would be just to give an elementclassName
like<section className='myClass'>hello world</section>
and then just to add desired properties in your .css file which you can import in your component or globally.
It is not possible to add hover with in-line styles.