1
与React-Router的活动链接?
我正在尝试React-Router(v4),但从Nav开始让Linkbe之一出现问题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> )