我是React.js的新手,使用锚点时遇到了麻烦。我只想将导航菜单之一链接到www.google.com,例如:
render() {
return (
<div className='sidebar__content'>
<ul className='sidebar__block'>
<SidebarLink title='Home' icon='home' route='/home' onClick={this.hideSidebar}/>
<SidebarLink title='Master List' icon='store' route='/master_list' onClick={this.hideSidebar}/>
<SidebarCategory title='Layout' icon='layers'>
<li className='sidebar__link' onClick={this.changeToLight}>
<p className='sidebar__link-title'>Light Theme</p>
</li>
<li className='sidebar__link' onClick={this.changeToDark}>
<p className='sidebar__link-title'>Dark Theme</p>
</li>
</SidebarCategory>
<SidebarCategory title='Dashboards' icon='diamond'>
<a href="https://www.google.com"><SidebarLink title='Daily Sales' onClick={this.hideSidebar}/></a>
<SidebarLink title='Daily Profit' route='/pages/two' onClick={this.hideSidebar}/>
</SidebarCategory>
有人能指出我正确的方向吗?
<SidebarCategory title='Dashboards' icon='diamond'>
<a href="https://www.google.com"><SidebarLink title='Daily Sales' onClick={this.hideSidebar}/></a>
我尝试过:
<Route path='/privacy-policy' component={() => window.location = 'https://www.google.com'}/>
<SidebarLink title='Daily Sales'/><Route/>
<SidebarLink title='Daily Profit' route='/pages
和:
<SidebarCategory title='Dashboards' icon='diamond'>
<SidebarLink title='Daily Sales' onClick={() => window.location = 'https://www.google.com'}/>
<SidebarLink title='Daily Profit' route='/pages/two' onClick={this.hideSidebar}/>
</SidebarCategory>
这最后一个有效,但是我知道它是一个hack,登录页面在google.com之前出现了第二秒钟。有人可以告诉我正确的方法吗?