CRA应用部署二级路由问题
BrowserRouter 路由basename
写入window.location.pathname
1 2 3 4 5 6 7 8 9 10 11 12
| function App() { return ( <Provider store={store}> <BrowserRouter basename={window.location.pathname}> <div id="container"> <Route path={'/about'} component={AboutPage} /> <Route exact path={'/'} component={IndexPage} /> </div> </BrowserRouter> </Provider> ); }
|
package.json 加入homepage:'.'