下拉列表不适用于React-Router

时间:2016-05-18 17:51:19

标签: reactjs react-router materialize

我正在使用React-Router和MaterializeCSS,似乎导航栏内的每个哈希链接(href =“#”)都在路由中映射到不存在的页面,但我想要的只是打开下拉列表。

我该如何避免这种行为?如果我刷新页面,它就会起作用。

我的路线:

var React = require('react');
var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route;
var HashHistory = ReactRouter.hashHistory;
var Login = require('../containers/loginContainer');
var Base = require('../containers/shared/baseContainer');
var Dashboard = require('../components/dashboard');


var Routes = (
  <Router history={HashHistory}>
      <Route path='/' component={Login}/>
      <Route component={Base}>
          <Route path='/Dashboard' component={Dashboard}>
          </Route>
      </Route>
   </Router>
)

module.exports = Routes;

我的导航栏(位于Base组件内):

<ul id="dropdown1" className="dropdown-content">
 <li><a href="#!">Cadastrar</a></li>
 <li><a href="#!">Listar</a></li>
</ul>
<nav>
  <div className="nav-wrapper">
    <Link to="/" className="brand-logo">Logo</Link>
    <ul className="right hide-on-med-and-down">
      <li><a className="dropdown-button" href="#!" data-activates="dropdown1">Funcionários<i className="material-icons right">arrow_drop_down</i></a></li>
     </ul>
  </div>
</nav>

0 个答案:

没有答案