我正在尝试React-Router(v4),但从Nav开始让Link
be之一出现问题active
。如果我单击任何Link
标签,则活动的东西开始工作。但是,我希望HomeLink
能够在应用启动后立即启动,因为那是在/
路线上加载的组件。有什么办法吗?
这是我当前的代码:
const Router = () => (
<BrowserRouter>
<div>
<Nav>
<Link activeClassName='is-active' to='/'>Home</Link> {/* I want this to start off as active */}
<Link activeClassName='is-active' to='/about'>About</Link>
</Nav>
<Match pattern='/' exactly component={Home} />
<Match pattern='/about' exactly component={About} />
<Miss component={NoMatch} />
</div>
</BrowserRouter>
)