首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法获取:悬停或任何伪类以在react + material UI中工作

无法获取:悬停或任何伪类以在react + material UI中工作
EN

Stack Overflow用户
提问于 2018-06-22 05:12:05
回答 2查看 2K关注 0票数 0

我已经让所有其他样式对象正常工作了,但是由于某些原因,伪类似乎不能呈现,或者它们抛出了一个错误,我使用的是jss-preset-default设置。在jssTest组件下面是我尝试过的不同组合的注释示例,以及我检查它们时它们的呈现方式。

代码语言:javascript
复制
import React, { Component } from "react";
import { withStyles } from "@material-ui/core/styles";

const styles = theme => ({
    root: {
        color: "#ff0000",
        "&:hover": {
            color: "#0000ff"
        }
    }
});

class JssTest extends Component {
    render() {
        return (
            <div>
                <h1 style={styles("").root}>JSS Test</h1>
            </div>
        );
    }
}

//<h1 classes={styles("").root}>JSS Test</h1>
//Styles nothing and Renders as
//<h1 classes="[object Object]">JSS Test</h1>

//<h1 style={styles("").root}>JSS Test</h1>
//Renders just the color but not the '&:hover'
//<h1 style="color: rgb(255, 0, 0);">JSS Test</h1>

//<h1 classes={classes.root}>JSS Test</h1>
//get   Line 18:  'classes' is not defined  no-undef

//<h1 classes={styles.root}>JSS Test</h1>
//renders as
//<h1>JSS Test</h1>

export default withStyles(styles)(JssTest);
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50977502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档