Material-UI组件未显示在本地主机应用程序上,有来自material-ui的工具栏组件,但它没有在浏览器中显示。我在下面提到了package.json。
我使用creat-react-app创建了应用程序。它以前工作但有些它现在不工作。
先谢谢你帮助我。
的package.json
{
"name": "reactx",
"version": "0.1.0",
"private": true,
"homepage": ".",
"devDependencies": {
"react-scripts": "1.0.16"
},
"dependencies": {
"material-ui": "^1.0.0-beta.21",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-router": "^4.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
app.js
import React, { Component } from 'react';
import { HashRouter, Route } from 'react-router-dom';
import Toolbar from './toolbar/toolbar';
import './app.css';
class App extends Component {
render() {
return (
<HashRouter>
<div>
<Route path="/toolbar" component={ Toolbar } />
</div>
</HashRouter>
);
}
}
export default App;
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './app';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
toolbar.js
import React from 'react';
import AppBar from 'material-ui/AppBar';
import Toolbar from 'material-ui/Toolbar';
import Typography from 'material-ui/Typography';
export default () =>
<AppBar position="static" color="primary">
<Toolbar>
<Typography type="title" color="inherit">
My App
</Typography>
</Toolbar>
</AppBar>
toolbar.css
No CSS here