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
Module '...' resolves to a non-module entity and cannot be imported using this construct
提问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.ts
file.
这是来自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');