我将使用Gitlab Pages。似乎Gitlab Pages与React Router不兼容,我会得到一个空白页面。如何使用Gitlab Pages和React Router呢?该怎么解决这个问题?
/src/App.js
/src/App.js
import React from 'react';
import { Route } from 'react-router-dom';
import HomePage from './components/pages/HomePage';
import LoginPage from './components/pages/LoginPage';
const App = () => (
<div>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact component={LoginPage} />
</div>
);
export default App;
src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
registerServiceWorker();
HashRouter
还是BrowserRouter
? - drinchev