3

安装后,我从文档中复制了这段确切的代码npm install @mui/styles

import * as React from 'react';
import { makeStyles } from '@mui/styles';
import Button from '@mui/material/Button';

const useStyles = makeStyles({
  root: {
    background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
    border: 0,
    borderRadius: 3,
    boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
    color: 'white',
    height: 48,
    padding: '0 30px',
  },
});

export default function Hook() {
  const classes = useStyles();
  return <Button className={classes.root}>Hook</Button>;
}

在我的本地机器上,它似乎忽略了颜色白色属性、边框属性以及框阴影。是否有一个原因?我已经在我的 package.json 中确认我正在运行 mui-material/styles 5.2.3

4

1 回答 1

2

我相信会回答你的问题。因为makeStyles在 MUI V5 中已弃用。

您始终可以使用sxprop 添加自定义主题。

我有同样的问题,这篇关于开发的文章救了我。

于 2021-12-22T02:49:02.133 回答