typescript 模块“...”解析为非模块实体,无法使用此构造导入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35277354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:16:18  来源:igfitidea点击:

Module '...' resolves to a non-module entity and cannot be imported using this construct

typescriptmaterial-ui

提问by Raul Tomescu

I have a .tsx file in which I am trying to import a RaisedButton component from material-ui like so:

我有一个 .tsx 文件,我试图在其中从 material-ui 导入 RaisedButton 组件,如下所示:

import * as RaisedButton from 'material-ui/lib/raised-button'

However, that gives me the error described in the title, any ideas what I might be doing wrong?

但是,这给了我标题中描述的错误,任何想法我可能做错了什么?

回答by Blake Bowen

This is from the material-ui.d.tsfile.

这是来自material-ui.d.ts文件。

export import RaisedButton = __MaterialUI.RaisedButton; // require('material-ui/lib/raised-button');

So you should import it like this.

所以你应该像这样导入它。

import RaisedButton = require('material-ui/lib/raised-button');