【发布时间】:2018-03-12 09:10:35
【问题描述】:
我想获取我所在页面的位置,以便设置条件渲染。最初,我有这样的设置
const currentPath = window.location.pathname;
...
<h1>{currentPath}</h1>
这会将路径回显为http://example.com/page。
但由于我已经切换到使用 HashRouter,并且页面链接生成类似于http://example.com/#/page,因此唯一回显的是“/”
如何获取哈希后的页面位置?
【问题讨论】:
标签: javascript reactjs react-router