简体   繁体   English

如何在页面中使用React Router v1.0.0进行链接

[英]how to link in a page with React Router v1.0.0

I want to link to a specific section section of a page with react router a lot like how anchor tags would work in html. 我想链接到一个页面的特定部分与反应路由器很像锚标签在html中的工作方式。 However, I couldn't find solutions with React Router version 1.0.0. 但是,我找不到React Router版本1.0.0的解决方案。

Currently, i have my router like this: 目前,我的路由器是这样的:

let history = createHashHistory({
    queryKey: false
});

<Router history={history}>
        <Route path="/" component={a}/>
        <Route path="/b" component={b}/>
        <Route path="/c" component={c}/>
        <Route path="/d" component={d}/>
        <Route path="/e" component={e}/>
        <Route path="/f" component={f}/>
        <Route path="/g" component={g}/>
 </Router>

and I am trying to link to a specific section in the components like 我试图链接到组件中的特定部分,如

 <Link to="/b#{div_id}"> Go to section with div_id is component {b} </Link>

There is currently an open issue on GitHub for this. 目前GitHub上有一个未解决的问题。 It doesn't appear to be supported, but it should be supported when using HistoryLocation when this issue is fixed. 它似乎不受支持,但在HistoryLocation此问题时使用HistoryLocation时应该支持它。

EDIT 编辑

This is no longer supported . 不再受支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM