[英]React JS - React Material UI icons not working?
I am using react Material UI, and I received the following error.我正在使用 React Material UI,但收到以下错误。
"Module not found: Can't resolve '@material-ui/icons/Lock'"
“未找到模块:无法解析‘@material-ui/icons/Lock’”
import LockIcon from '@material-ui/icons/Lock';
How can I fix this?我怎样才能解决这个问题?
import Icon from '@material-ui/core/Icon';
然后将字体材质图标添加到index.html
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
You haven't installed @material-ui/icons
package. 您尚未安装
@material-ui/icons
包。 You can validate it from node_modules
您可以从
node_modules
验证它
This would resolve your issue, 这可以解决您的问题,
npm install --save @material-ui/icons
MUI have since separated their icons
from core into a separate node_module called @material-ui/icons
. MUI 已经将他们的
icons
从核心分离到一个名为@material-ui/icons
的单独 node_module 中。
Here's a good example on how to setup your MUI Icons with React: https://mechanicalrock.github.io/2021/04/27/fed-talk-s01e01-getting-started#keyboard-getting-started-with-material-ui这是一个关于如何使用 React 设置 MUI 图标的好例子: https : //mechanicalrock.github.io/2021/04/27/fed-talk-s01e01-getting-started#keyboard-getting-started-with-material-用户界面
Here's an alternative is you cant install the node modules:这是您无法安装节点模块的替代方法:
You can find more info about all the icons here您可以在此处找到有关所有图标的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.