我需要在点击标签上添加活动类css,这是代码:
<ul>
<li className="step"><Link to={`${this.props.match.url}/personal-information`} >You <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/content`}>Content <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/profile-information`}>Profile <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/rewards`}>Rewards <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/goals`}>Goals <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/thanks`}>Thanks <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/payment`}>Payment <i className="fa fa-long-arrow-right"></i></Link></li>
<li className="step"><Link to={`${this.props.match.url}/launch`}>Launch! </Link></li>
</ul>
答案 0 :(得分:0)
You can use NavLink, which is
&#34;将添加样式属性的特殊版本 当与当前URL匹配时,呈现的元素。&#34;
It has a property called activeClassName which handles the active link.
example :
<NavLink
to="/faq"
activeClassName="selected"
>FAQs</NavLink>
中找到更多信息