Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 蓝色按钮代替紫色_Reactjs_Material Ui - Fatal编程技术网

Reactjs 蓝色按钮代替紫色

Reactjs 蓝色按钮代替紫色,reactjs,material-ui,Reactjs,Material Ui,我有一个带有react的材质ui,当添加一个按钮并将颜色设置为primary时,它会变成紫色。基于以下网站,我希望它是蓝色的: 代码: 如何使此按钮变为蓝色?按钮的颜色使用材质UI的颜色主题。 查看要覆盖的文档样式: 有很多解决方案,但在这里您可以使用内联样式,如: style={{background: 'blue'}} 以下是一个例子: 按钮的颜色使用材质UI的颜色主题。 查看要覆盖的文档样式: 有很多解决方案,但在这里您可以使用内联样式,如: style={{background:

我有一个带有react的材质ui,当添加一个按钮并将颜色设置为primary时,它会变成紫色。基于以下网站,我希望它是蓝色的:

代码:


如何使此按钮变为蓝色?

按钮的颜色使用材质UI的颜色主题。 查看要覆盖的文档样式:

有很多解决方案,但在这里您可以使用内联样式,如:

style={{background: 'blue'}}
以下是一个例子:
按钮的颜色使用材质UI的颜色主题。 查看要覆盖的文档样式:

有很多解决方案,但在这里您可以使用内联样式,如:

style={{background: 'blue'}}
以下是一个例子:

那里有一个指向代码沙盒的链接。它显示页面上的其他颜色。所以我猜他们只是在网站上过时了,你的颜色是新的

如果你真的想要蓝色,你应该使用Material UI的“withStyles”功能,如你发布的页面所述

import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';

const styles = theme => ({
  button: {
    backgroundColor: 'blue',
  }
});

function ContainedButtons(props) {
  const { classes } = props;
  return (
    <div>
      <Button variant="contained" color="primary" className={classes.button}>
        Primary
      </Button>
    </div>
  );
}

ContainedButtons.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(ContainedButtons);

他们有一个指向代码沙盒的链接。它显示页面上的其他颜色。所以我猜他们只是在网站上过时了,你的颜色是新的

如果你真的想要蓝色,你应该使用Material UI的“withStyles”功能,如你发布的页面所述

import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';

const styles = theme => ({
  button: {
    backgroundColor: 'blue',
  }
});

function ContainedButtons(props) {
  const { classes } = props;
  return (
    <div>
      <Button variant="contained" color="primary" className={classes.button}>
        Primary
      </Button>
    </div>
  );
}

ContainedButtons.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(ContainedButtons);

材质UI文档站点使用自定义主题。文档中提到了这一点,请参阅。主题对象是可自定义的

如果您希望使用与文档相同的颜色组合,则需要使用主题化。此处提供了一个示例-

例如,您可以执行如下操作,以获得与文档站点相同的原色

从React导入React; 从@material ui/core导入{Button}; 从@material ui/core/styles导入{CreateMuiteme,ThemeProvider}; const theme=createMuiTheme{ 调色板:{ 主要:{ 主要电话:1976d2 }, 中学:{ 主要电话:dc004e } } }; 导出默认函数自定义样式{ 回来 主要的,重要的 ;
} 材质UI文档站点使用自定义主题。文档中提到了这一点,请参阅。主题对象是可自定义的

如果您希望使用与文档相同的颜色组合,则需要使用主题化。此处提供了一个示例-

例如,您可以执行如下操作,以获得与文档站点相同的原色

从React导入React; 从@material ui/core导入{Button}; 从@material ui/core/styles导入{CreateMuiteme,ThemeProvider}; const theme=createMuiTheme{ 调色板:{ 主要:{ 主要电话:1976d2 }, 中学:{ 主要电话:dc004e } } }; 导出默认函数自定义样式{ 回来 主要的,重要的 ;
}您是否使用@material ui/core/styles';如果您的问题得到解决,请关闭此帖子。您是否使用@material ui/core/styles';如果你的问题解决了,请关闭此帖子。