是否可以从外部组件获取当前路由?
基本上,我有一个页面标题组件,只显示当前页面标题。似乎无法弄清楚如何从外部组件访问路由?
编辑: 的 App.jsx
=COUNTIF(sheet2!$B:$B,A1)
的路线
<div style={styles.container}>
<Sidebar style={styles.sidebar} links={sidebarLinks}/>
<div style={styles.wrapper}>
<Header style={styles.header}/>
<div style={styles.content}>
<PageTitle style={styles.pageTitle} /> //Want current route here
{this.props.children}
</div>
<Footer style={styles.footer}/>
</div>
</div>
答案 0 :(得分:1)
不确定你在问什么。也许您可以使用window.location
API:
window.location.href
或
window.location.pathname