IconButton未显示在屏幕上

问题描述 投票:1回答:1

我刚刚开始学习React.js和material-ui。我正在使用this在屏幕上显示一个图标。但是,图标不会显示在屏幕上,并且屏幕显示为空白。

这是我的代码:

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import {IconButtonExampleSimple} from './IconButtonExampleSimple.js';


 class App extends  React.Component{

 render()
 {
   return(
         <MuiThemeProvider>
         <IconButtonExampleSimple />
         </MuiThemeProvider>
         );
  }
 }




    ReactDOM.render(
                    <App/>,
                    document.getElementById('root')
                    );

IconButtonExampleSimple.js

  import React from 'react';
  import IconButton from 'material-ui/IconButton';
   export class IconButtonExampleSimple extends React.Component{

   render ()
  {
   return (<div>
             <IconButton iconClassName="muidocs-icon-custom-github" />
             <IconButton iconClassName="muidocs-icon-custom-github" 
             disabled={true} />
           </div>
          );
   }
   }
reactjs material-ui
1个回答
1
投票

将此行添加到index.html

<link href="https://fonts.googleapis.com/icon?family=Material+Icon‌​s" rel="stylesheet">

您正在包含图标按钮的Material-UI部分,但这些部分指的是Google的Material-Icons,因此您必须将其链接到索引文件中。

© www.soinside.com 2019 - 2024. All rights reserved.