我已经让所有其他样式对象正常工作了,但是由于某些原因,伪类似乎不能呈现,或者它们抛出了一个错误,我使用的是jss-preset-default设置。在jssTest组件下面是我尝试过的不同组合的注释示例,以及我检查它们时它们的呈现方式。
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);https://stackoverflow.com/questions/50977502
复制相似问题