Я пытаюсь использовать Material-UI в Xampp, но я не уверен, что мой код React.js содержит ошибки или мои пакеты неверны.Я прошел через эти вопросы, но все еще ничего не достиг: Начало работы с material-ui , как мне запустить материал-ui локально , Команда `npm start` ничего не делает
Я пытался сделать Начало работы с material-ui , как мне запустить материал-ui локально , Команда `npm start` ничего не делает.
Удаление установленных пакетов npm и переустановка с использованием yarn.
Я попытался запустить сервер Node.js, используя npm install connect serve-static
после того, как сделал npm install
, и запустить сервер на локальном хосте.: 8000 с node server
Я также попытался запустить его на пряжу и сделал yarn
для установки пакетов, затем запустил его с yarn run start
на порту 3000.
Я попытался переустановить всено безрезультатно.
index.js
import React from 'node_modules/react';
import ReactDOM from 'node_modules/react-dom';
import Demo from './demo';
ReactDOM.render(<Demo />, document.getElementById("root"));
demo.js
import React from 'node_modules/react';
import PropTypes from 'node_modules/prop-types';
import { withStyles } from 'node_modules/@material-ui/core/styles';
import AppBar from 'node_modules/@material-ui/core/AppBar';
import Toolbar from 'node_modules/@material-ui/core/Toolbar';
import Typography from 'node_modules/@material-ui/core/Typography';
import Button from 'node_modules/@material-ui/core/Button';
import IconButton from 'node_modules/@material-ui/core/IconButton';
import MenuIcon from 'node_modules/@material-ui/icons/Menu';
const styles = {
root: {
flexGrow: 1,
},
grow: {
flexGrow: 1,
},
menuButton: {
marginLeft: -12,
marginRight: 20,
},
};
function ButtonAppBar(props) {
const { classes } = props;
return (
<div className={classes.root}>
<AppBar position="static">
<Toolbar>
<IconButton className={classes.menuButton} color="inherit" aria-label="Menu">
<MenuIcon />
</IconButton>
<Typography variant="h6" color="inherit" className={classes.grow}>
News
</Typography>
<Button color="inherit">Login</Button>
</Toolbar>
</AppBar>
</div>
);
}
ButtonAppBar.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(ButtonAppBar);
server.js
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8000);
index.html
<body>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<div id="root"></div>
</body>
Я ожидал, что веб-страница будет отображаться, но я только что получил код веб-сайта при доступе к localhost в Xampp.