[英]Attempted import error: 'alpha' is not exported from '@material-ui/core/styles'
I'm trying to use the material-ui/lab date picker, however I'm getting this error!我正在尝试使用 material-ui/lab 日期选择器,但出现此错误! I have updated my material-ui version using npm install @material-ui/core@latest
and it worked fine.我已经使用npm install @material-ui/core@latest
更新了我的 material-ui 版本,它运行良好。 However, I lost the ability to use createMuiTheme
& MuiThemeProvider
.但是,我失去了使用createMuiTheme
& MuiThemeProvider
的能力。
Maybe it'll be helpful for someone.也许它会对某人有所帮助。 For me fix of that issue was to change the indirect import to direct one:对我来说,解决这个问题的方法是将间接导入更改为直接导入:
so this triggered the error:所以这触发了错误:
import { Alert } from '@material-ui/lab';
this works fine:这工作正常:
import Alert from '@material-ui/lab/Alert';
I had the same problem with Skeleton using version @material-ui/lab": "4.0.0-alpha.60 but changing it to version @material-ui/lab": "4.0.0-alpha.57 fixed it for me... guess they broke it again:)我在使用版本 @material-ui/lab 的 Skeleton 时遇到了同样的问题”:“4.0.0-alpha.60 但将其更改为版本 @material-ui/lab”:“4.0.0-alpha.57 为我修复了它...猜猜他们又把它弄坏了:)
You should update your package.json with following:您应该使用以下内容更新您的 package.json:
"@material-ui/lab": "4.0.0-alpha.57",
"@material-ui/pickers": "3.2.10",
I was using MUI v4 and was trying to use the Appbar from MUI, updating my MUI by running the command npm install @material-ui/core@latest
and restarting the server by using npm start
worked for Me, Hope this helps!!我正在使用 MUI v4 并尝试使用 MUI 中的 Appbar,通过运行命令npm install @material-ui/core@latest
更新我的 MUI,并通过使用npm start
重新启动服务器对我有用,希望这有帮助!!
I had to downgrade npm node@11.15.0
and npm install @material-ui/core@4.12.1
then it fixed all issues.我不得不降级npm node@11.15.0
和npm install @material-ui/core@4.12.1
然后它解决了所有问题。 Please check node version with your node.请使用您的节点检查节点版本。
My material-ui version when first downloaded was an earlier version.首次下载时,我的 material-ui 版本是早期版本。 Then i ran:然后我跑了:
npm i -g npm-check-updates
ncu -u
npm install
to let it upgrade automatically to latest version.让它自动升级到最新版本。
Please try updating to latest version of @material-ui/core
.请尝试更新到最新版本的@material-ui/core
。 That should fix the issue.那应该可以解决问题。
i can't solve this problem with above solutions.我无法用上述解决方案解决这个问题。
so manually change 'alpha' to 'fade' in material ui files所以在材质 ui 文件中手动将 'alpha' 更改为 'fade'
./node_modules/@material_ui/lab/esm/ ./node_modules/@material_ui/lab/esm/
for example:例如:
import { fade, withStyles, useTheme } from '@material-ui/core/styles';从'@material-ui/core/styles'导入{淡入淡出,withStyles,useTheme};
import { alpha, withStyles, useTheme } from '@material-ui/core/styles';从 '@material-ui/core/styles' 导入 { alpha, withStyles, useTheme };
it's works for me这对我有用
but it's not correct solutions.但这不是正确的解决方案。
update npm @material-ui/cor
e package npm update
resolved my issue更新npm @material-ui/cor
e package npm update
解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.