我创建了react app react router 4,但是我使用npm run build
路由URL无法构建我的项目并显示404页面。如何解决该问题?我不知道。这是我的代码
import React from "react";
import ReactDOM from "react-dom";
import registerServiceWorker from "./registerServiceWorker";
import { BrowserRouter as Router } from "react-router-dom";
/* Material UI Components */
import { createMuiTheme, MuiThemeProvider } from "@material-ui/core/styles";
/* Styles */
import "react-datepicker/dist/react-datepicker-cssmodules.css";
import "./styles/main.scss";
/* Components */
import App from "../App";
import AdminHome from "../pages/admin/home";
import Login from "../pages/login";
import PrivateRoute from "./privateRoute";
/* App Theme */
const theme = createMuiTheme({
palette: {
type: "dark"
}
});
ReactDOM.render((
<Router>
<MuiThemeProvider theme={theme}>
<Switch>
<PrivateRoute exact path={"/"} component={App}/>
<PrivateRoute path={"/admin"} component={AdminHome}/>
<Route path={"/login"} component={Login}/>
<Route render={() => <p>Not Found</p>}/>
</Switch>
</MuiThemeProvider>
</Router>
), document.getElementById("root"));
registerServiceWorker();
有人可以帮我解决这个问题吗?