使用Component Lab>编译错误. Material UI中SVG图标的自动完成功能 [英] Compile error using the Component Lab > Autocomplete feature for SVG Icons in Material UI

查看:82
本文介绍了使用Component Lab>编译错误. Material UI中SVG图标的自动完成功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器上运行项目时出现以下错误:

I got the following error when I ran my project on the browser:

无法编译:

./node_modules/@material-ui/lab/esm/internal/svg-icons/Close.js
Attempted import error: 'createSvgIcon' is not exported from '@material-ui/core/utils'.

我正在尝试实现自动填充组件(来自多个值"部分).

I'm trying to implement the Autocomplete component (from the example in the "Multiple values" section).

这是我正在使用的代码:

Here is the code I'm using:

import React from 'react';
import Chip from '@material-ui/core/Chip';
import Autocomplete from '@material-ui/lab/Autocomplete';
import TextField from '@material-ui/core/TextField';

<Autocomplete
        multiple
        id="tags-standard"
        options={top100Films}
        getOptionLabel={(option) => option.title}
        defaultValue={[top100Films[13]]}
        renderInput={(params) => (
          <TextField
            {...params}
            variant="standard"
            label="Multiple values"
            placeholder="Favorites"
          />
        )}
      />

我试图通过NPM安装SVG图标:

I tried to install SVG Icons by NPM:

npm install @material-ui/icons

然后将它们导入我的TypeScript:

And then importing them to my TypeScript:

import createSvgIcon from '@material-ui/icons/utils/createSvgIcon';

但是我仍然有上面的错误.我该如何解决这个问题?

But I still have the error above. How can I resolve this issue?

推荐答案

您是否可以尝试通过运行来更新@material-ui/core

Can you try to update @material-ui/core by running

npm update

这篇关于使用Component Lab&gt;编译错误. Material UI中SVG图标的自动完成功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆