0

我正在尝试在我的反应应用程序中使用 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;
4

1 回答 1

0

您不需要为 node_modules 设置确切的路径,只需输入组件名称即可导入任何组件。就像下面材料 ui doc 中的 import 语句一样。

import Button from '@material-ui/core/Button';
于 2018-09-16T07:12:40.800 回答