2017-10-17 22 views
0

我是使用npm並在Visual Studio中作出反應的新手。試圖爲我的React項目安裝Material-UI @,但在運行項目時收到這些警告。在Visual Studio中安裝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

明顯的東西我失蹤?

+0

您是否使用AMD模塊加載器(即CommonJS或RequireJS)?... – War10ck

+0

不,我不這麼認爲。我正在使用webpack打包js文件。該項目基於Visual Studio模板「React.js和Redux」,迄今爲止唯一的變化是添加Material-UI。 – Rob

+0

什麼版本的visual studio? –

回答

1

我得到了最新的Material-UI與.Net核心的'react/redux'模板一模一樣的問題。我發現它是一個爲了獲得正確版本的依賴關係的問題。

爲了得到它的工作,我所有的軟件包更新到最新版本:

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

一旦我更新的裁判,一些示例代碼的爆發。所以我只是刪除了破碎的比特,因爲我所關心的是獲得Material-UI的工作。

一旦我有了這部分,我只需要做適當的導入,並能夠使用紙張元素。

這是我如何得到它的一個例子。

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

祝你好運!

編輯: 我更新了回購並修復了我找到的任何版本問題。我會盡量讓這個回購儘可能地更新。乾杯!