React-Redux如何在生产中处理斜杠(/)。从根重定向

时间:2019-03-26 16:33:01

标签: reactjs build react-router production

我有一个来自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;

0 个答案:

没有答案