Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问一下404路由怎么配置,不设置path的404component,每个页面滑动到底部都会出现404的页面 #17

Open
jaydenxiao2016 opened this issue Jun 4, 2019 · 3 comments

Comments

@jaydenxiao2016
Copy link

请问一下404路由怎么配置,不设置path的404component,每个页面滑动到底部都会出现404的页面

@fi3ework
Copy link
Owner

fi3ework commented Jun 4, 2019

可以提供一下路由那块的代码吗,或者可以先参考下:

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 使用

@jaydenxiao2016
Copy link
Author

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>
    )
}

@jaydenxiao2016
Copy link
Author

试了你的方法,貌似没起效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants