import React from "react";
import ReactDOM from "react-dom";
import "bootstrap/dist/css/bootstrap.min.css";
import Router from "./components/Router";
import * as serviceWorker from "./serviceWorker";
ReactDOM.render(<Router />, document.getElementById("root"));
serviceWorker.unregister();
我已经部署了我的应用程序来做出反应,但是它只是在白屏显示我在做什么错。我已经将习惯和应用程序也更改为。我也使用了路由器来HashRouter
,而不是BrowserRouter
。
//Package json
{
"name": "react-movie-world-app",
"version": "0.1.0",
"private": true,
"homepage": "https://myusername.github.io/myappname",
"dependencies": {
"bootstrap": "^4.3.1",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.9",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.0.1"
}
}
//Router js file
import React from "react";
import { HashRouter, Switch, Route } from "react-router-dom";
import App from "../App";
import Contact from "./Pages/Contact";
// import Form from "./Form";
import Movie from "./Movie";
const Router = () => (
<HashRouter>
<Switch>
<Route path="/" component={App} exact />
<Route path="/contact" component={Contact} />
<Route path="/movie" component={Movie} />
</Switch>
</HashRouter>
);
export default Router;