我正在开发一个带有reactjs的应用程序
我运行了npm run build,并将build文件夹的内容移动到xampp服务器
404 Not Found错误提示页面未找到
我将路由从BrowserHistory更改为HashRouter
但问题依然存在。
index.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { Provider } from "react-redux";
import { persistor, store } from "./noautharea/redux/store";
import { PersistGate } from "redux-persist/integration/react";
import { HashRouter as Router } from "react-router-dom";
ReactDOM.render(
<Provider store={store}>
<Router>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</Router>
</Provider>,
document.getElementById("root")
);
reportWebVitals();
App.js
function App() {
const receptionist = "receptionist";
return (
<div className="App">
<Routes>
<Route path="/manager/login" element={<Manager />} />
<Route path="/receptionist/login" element={<Receptionist />} />
<Route path="/" exact element={<Receptionist />} />
</Routes>
</div>
)
}
1条答案
按热度按时间brqmpdu11#
尝试将App.js更改为:
我认为问题是HashRouter将在“/#/”上呈现,而不是在“/”上呈现