Material-UI @next不支持基于道具的样式?

时间:2017-08-11 01:13:38

标签: reactjs material-ui

随着Material-UI @的到来,接下来将基于CSS-to-JS的样式替换为基于LESS的样式。但是,Material-UI's website上的组件演示似乎忽略了基于道具的样式的创建。我试图在我的页面上创建包含特定绝对高度的各种Material-UI组件的div,但是,在类之外预定义样式表的要求意味着样式表中的属性可以&# 39; t基于传递给组件的道具。我错过了什么吗?

例如:

import React, {Component} from 'react';
import {withStyles, createStyleSheet} from 'material-ui/styles';
import Button from 'material-ui/Button';
const styleSheet = createStyleSheet({
    container: {
        position: "absolute",
        top: /*How can this be dependent upon the props passed to the component?*/,
        height: /*How can this be dependent upon the props passed to the component?*/,
    }
});
class Foo extends Component {

  render() {
        let classes = this.props.classes;
    return (
      <div className={classes.container}>
        <Button raised/>
      </div>
    );
  }
}

export default withStyles(styleSheet)(Foo);

上面显示的示例组件不能具有props - 依赖样式,因为在创建样式表时未定义props。那么我该如何解决这个问题呢? IS 有解决方案吗?

0 个答案:

没有答案
相关问题