react-live-route
react-live-route copied to clipboard
请问一下404路由怎么配置,不设置path的404component,每个页面滑动到底部都会出现404的页面
请问一下404路由怎么配置,不设置path的404component,每个页面滑动到底部都会出现404的页面
可以提供一下路由那块的代码吗,或者可以先参考下:
function App() {
return (
<div className="App">
<Switch>
<Route exact path="/" component={Home} />
<Route path="/item/:id" component={Detail} />
<Route path="/about" component={About} />
<Route path="/items" /> // 占位
<Route path="*" render={NotFound} />
</Switch>
<LiveRoute
path="/items"
component={List}
livePath="/item/:id"
name="items"
onHide={routeState => {
console.log("[on hide]");
console.log(routeState);
}}
onReappear={routeState => {
console.log("[on reappear]");
console.log(routeState);
}}
/>
<Bar />
</div>
);
}
如何配合 Switch 使用
render() {
return (
<HashRouter>
<div style={{height: "100%"}}>
<ScrollToTopComponent>
{/*首页*/}
<LiveRoute path={RoutePath.Home} exact alwaysLive={true} component={Home}/>
{/*----------------------指纹倒查路由begin---------------------------*/}
{/*指纹比中情况查询*/}
<LiveRoute
path={RoutePath.FingerComparisonListPage} component={FingerComparisonListPage}
livePath={[RoutePath.FingerComparisonDetailPage, RoutePath.FingerComparisonPersonInfoPage, RoutePath.FingerComparisonSealUnitPage]}
/>
{/*比中详情*/}
<LiveRoute
path={RoutePath.FingerComparisonDetailPage} component={FingerComparisonDetailPage}
/>
{/*人员信息筛选*/}
<LiveRoute
path={RoutePath.FingerComparisonPersonInfoPage} component={FingerComparisonPersonInfoPage}
/>
{/*捺印单位*/}
<LiveRoute
path={RoutePath.FingerComparisonSealUnitPage} component={FingerComparisonSealUnitPage}
/>
{/*关于*/}
<Route path={RoutePath.AboutPage}
component={AboutPage}/>
{/*图片查看*/}
<Route path={RoutePath.ImageBrowsePage}
component={ImageBrowsePage}/>
</ScrollToTopComponent>
</div>
</HashRouter>
)
}
试了你的方法,貌似没起效