我正在尝试在我的React应用程序中使用MUI现成的组件, 我可以正确导入所有内容,毕竟在运行应用程序后,浏览器中仅显示元素,而不是其样式。
import React, { Component } from 'react';
import Button from '../node_modules/muicss/lib/react/button';
class App extends Component {
render() {
return (
<div>
<div>
<Button size="small" color="primary">button</Button>
<Button size="small" color="primary" variant="flat">button</Button>
<Button size="small" color="primary" variant="raised">button</Button>
<Button size="small" color="primary" variant="fab">+</Button>
</div>
<div>
<Button color="primary">button</Button>
<Button color="primary" variant="flat">button</Button>
<Button color="primary" variant="raised">button</Button>
<Button color="primary" variant="fab">+</Button>
</div>
<div>
<Button size="large" color="primary">button</Button>
<Button size="large" color="primary" variant="flat">button</Button>
<Button size="large" color="primary" variant="raised">button</Button>
<Button size="large" color="primary" variant="fab">+</Button>
</div>
</div>
);
}
}
export default App;
答案 0 :(得分:0)
您无需为node_modules设置确切的路径,只需输入要导入任何组件的组件名称即可。 就像下面的材料ui文档中的import语句一样。
import Button from '@material-ui/core/Button';