如何在react-router中从外部获取当前路由?

时间:2016-07-23 20:38:35

标签: reactjs routes react-router params

是否可以从外部组件获取当前路由?

基本上,我有一个页面标题组件,只显示当前页面标题。似乎无法弄清楚如何从外部组件访问路由?

编辑: 的 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>

1 个答案:

答案 0 :(得分:1)

不确定你在问什么。也许您可以使用window.location API:

window.location.href

window.location.pathname
相关问题