在visual studio反应项目中安装material-ui

问题描述 投票:0回答:1

我是新手使用npm并在Visual Studio中做出反应。试图为我的React项目安装Material-UI @,但在运行项目时收到了这些警告。

enter image description here

[at-loader] ./node_modules/material-ui/ButtonBase/ButtonBase.d.ts:12:11 
TS2694: Namespace 'React' has no exported member 'ButtonHTMLAttributes'.
[at-loader] ./node_modules/material-ui/ButtonBase/ButtonBase.d.ts:13:9 
TS2694: Namespace 'React' has no exported member 'AnchorHTMLAttributes'.
[at-loader] ./node_modules/material-ui/Chip/Chip.d.ts:4:18 
TS2430: Interface 'ChipProps' incorrectly extends interface 'HTMLAttributes<HTMLDivElement>'.
Types of property 'label' are incompatible.
Type 'ReactNode' is not assignable to type 'string | undefined'.
  Type 'null' is not assignable to type 'string | undefined'.
[at-loader] ./node_modules/material-ui/Form/FormControl.d.ts:5:17 
TS2694: Namespace 'React' has no exported member 'HtmlHTMLAttributes'.
[at-loader] ./node_modules/material-ui/Form/FormControlLabel.d.ts:13:11 
TS2694: Namespace 'React' has no exported member 'LabelHTMLAttributes'.
...

enter image description here

我错过了一些明显的东西?

visual-studio reactjs material-ui
1个回答
2
投票

我有完全相同的问题,让最新的Material-UI与.Net核心'react / redux'模板配合使用。我发现这是依次获取正确版本的依赖项的问题。

为了使其正常工作,我将所有软件包更新到最新版本:

$ npm install -g npm-check-updates $ npm-check-updates -u $ npm install

一旦我更新了这些引用,一些示例代码就破了。所以我只是删除了碎片,因为我所关心的是让Material-UI工作。

一旦我有了这个部分,我只需要进行正确的导入并且能够使用Paper元素。

这是我如何工作的一个例子。

https://github.com/cbehrends/MaterialUI_DotNetCore.git

祝好运!

编辑:我已经更新了回购并修复了我发现的任何版本问题。我将尝试尽可能地更新此repo。干杯!

© www.soinside.com 2019 - 2024. All rights reserved.