假设我的应用的基本网址是 example.com/app
是否可以在react-router中设置基本路由,而不是将所有路由写为
/app/a /app/b /app/c
我可以将它们指定为
a b c
我尝试了在文档中找到的以下示例,但它不起作用(页面不会显示任何内容)。也许是因为我使用的是react-router@3.0.0-alpha.1,或者我做错了什么。
import { useRouterHistory } from 'react-router'
import { createHistory } from 'history'
const history = useRouterHistory(createHistory)({
basename: '/app'
})
const Root = ({store}) => (
<Provider store={store}>
<Router history={history}>
<Route path='/' component={App}>
...
</Route>
</Router>
</Provider>
)
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号