简体   繁体   English

如何添加图标 MUI 数据表?

[英]How to add icon MUI Datatable?

I'm using MUI DataTable and I'm trying to add "Add Icon" to the toolbar.我正在使用 MUI DataTable 并且我正在尝试将“添加图标”添加到工具栏。 I've tried this: https://github.com/gregnb/mui-datatables/blob/master/examples/customize-toolbar/CustomToolbar.js but it didnt work.我试过这个: https : //github.com/gregnb/mui-datatables/blob/master/examples/customize-toolbar/CustomToolbar.js但它没有用。 Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义。 You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。 What's the proper and simplest way to add this icon?添加此图标的正确和最简单的方法是什么? I have no idea how to do this.我不知道该怎么做。

As I see in the provided link your class component is exported as default.正如我在提供的链接中看到的,您的类组件默认导出。 Thus, please make sure that, in the component that the MUI Datatable is located, you are importing the custom toolbar component like this:因此,请确保在 MUI 数据表所在的组件中,您正在导入自定义工具栏组件,如下所示:

import CustomToolbar from '...path/to/CustomToolbar'; 

and not like this:而不是这样:

import {CustomToolbar} from '...path/to/CustomToolbar';

您是否安装了@material-ui/icons

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM