我有一个来自React的构建包,一旦将其部署到名称为 admin
的服务器上,我就无法使用www.home.com/admin
进入该文件夹,因此在我的项目中,我需要附加/
,并在写 www.home.com/admin/
后执行我的项目。
我在package.json
"homepage": "."
中进行了更改,以建立相对路径,并且我使用了 HashRouter
该如何处理,因为每次我需要向浏览器中的路径添加/
import React, { Component } from 'react';
import './App.css';
import {Route, Switch, HashRouter as Router} from 'react-router-dom'
import {store ,persistor} from './components/store/index';
import { PersistGate } from 'redux-persist/integration/react';
import { Provider } from 'react-redux';
import Display from './components/displayMainScreen/displayMainScreen'
import SignIn from './components/login/indexLogin'
import Logs from './components/logs/logs';
class App extends Component {
render() {
return (
<div className="App">
<Provider store={store}>
<PersistGate persistor={persistor}>
<Router>
<Switch>
<Route exact path='/' component = {SignIn} />
<Route path='/login' component = {SignIn} />
<Route path='/display' component = {Display} />
<Route path='/logs' component = {Logs} />
</Switch>
</Router>
</PersistGate>
</Provider>
</div>
);
}
}
export default App;