我正在尝试从 @mui/material/Box
导入一个盒子组件。我使用以下命令安装了 MUI 5 npm i @mui/material
。但是这个错误正在发生, Module not found: Can't resolve '@emotion/react' in 'E:\frontend\node_modules\@mui\styled-engine'
这是我的代码。
import * as React from 'react';
import Box from '@mui/material/Box';
export default function WhiteSpace() {
return (
<div style={{ width: 200 }}>
<Box
component="div"
sx={{
whiteSpace: 'nowrap',
my: 2,
bgcolor: 'background.paper',
}}
>
White Space Nowrap. White Space Nowrap.
</Box>
<Box
component="div"
sx={{
whiteSpace: 'normal',
my: 2,
bgcolor: 'background.paper',
}}
>
White Space Normal. White Space Normal.
</Box>
</div>
);
}
有人可以帮我解决这个问题吗?
原文由 stmp_lee 发布,翻译遵循 CC BY-SA 4.0 许可协议
@emotion/react
and@emotion/styled
are peer dependencies of manymui
packages, ie@mui/material
.这使我们可以更自由地选择要使用的情感版本,但这确实意味着我们必须自己安装依赖项。