【问题标题】:Material-ui: Module not found: Can't resolve 'material-ui/Toolbar'Material-ui:找不到模块:无法解析“material-ui/Toolbar”
【发布时间】:2020-09-09 17:11:51
【问题描述】:

材质界面代码

我正在使用 React Material ui。尝试使用 Material UI 的 ToolBar 和 AppBar 组件。但是在使用这个时我得到了以下错误。找不到模块:无法解析'material-ui/core/Toolbar'

我做了一些研究并删除了这些软件包并重新安装了它们。但是,我一直收到我尝试使用两种导入方式导入的相同错误

不知道为什么会出现这个问题。我使用的@material-ui/core 版本有什么问题吗?

```
import React from 'react'
import AppBar from '@material-ui/core/AppBar';
import Toolbar from 'material-ui/core/Toolbar';
import {
    ListItem,
    IconButton,
    ListItemText,
    Avatar,
    Divider,
    List,
    Typography,
    Box
} from '@material-ui/core';
import {
    ArraowBack,
    AssignmentInd,
    Home,
    Apps,
    ContactMail,
    ArrowBack
} from "@material-ui/icons"

const Navbar = () => {
    return (
        <Box component="nav">
            <AppBar>
            <Toolbar>
                    <ArrowBack>

                    </ArrowBack>
                </Toolbar>  
            </AppBar>

        </Box>
    )
}

export default Navbar;

```

我正在使用 React Material ui。尝试使用 Material UI 的 ToolBar 和 AppBar 组件。但是在使用这个时我得到了以下错误。找不到模块:无法解析'material-ui/core/Toolbar'

我做了一些研究并删除了这些软件包并重新安装了它们。但是,我一直收到我尝试使用两种导入方式导入的相同错误

不知道为什么会出现这个问题。我使用的@material-ui/core 版本有什么问题吗?

【问题讨论】:

  • 它的@material-ui/core/Toolbar... 应该采取的调试步骤: 1) 与其他没有错误的组件相比,这个组件有什么不同? 2) 文档如何展示如何使用这个组件?
  • 谢谢你,我会记下你的建议

标签: javascript reactjs material-ui frontend


【解决方案1】:
import Toolbar from '@material-ui/core/Toolbar';
// or
import { Toolbar } from '@material-ui/core';

【讨论】:

    猜你喜欢
    • 2020-10-30
    • 2020-09-07
    • 1970-01-01
    • 2023-03-04
    • 2017-10-17
    • 2018-02-16
    • 2018-03-30
    • 2020-02-04
    • 2019-02-02
    相关资源
    最近更新 更多