React-Router不返回嵌套路由:警告:[react-router]位置“// profile”与任何路由都不匹配

时间:2016-05-16 03:22:36

标签: javascript reactjs react-router

我正在使用React-Router v.2.4.0并尝试在用户导航到路径#/?_k=mftgqo/profile时呈现嵌套路由。但是,我在浏览器中收到以下错误消息:

Warning: [react-router] Location "//profile" did not match any routes

App.js文件:

var React = require('react');
var ReactDOM = require('react-dom');
var Router = require('react-router').Router;
var hashHistory = require('react-router').hashHistory;
var routes = require('./routes');

ReactDOM.render(
  <Router history={hashHistory}>{routes}</Router>,
  document.getElementById('app')
)

routes.js file

var React = require('react');
var Main = require('./Main');
var Home = require('./Home');
var Profile = require('./Profile');
var Router = require('react-router');
var Route = Router.Route;
var IndexRoute = Router.IndexRoute;

module.exports = (
  <Route path='/' component={Main}>
    <Route path='profile' component={Profile} />
    <IndexRoute component={Home} />
  </Route>
);

索引路由正确呈现但不是配置文件路由。有什么想法吗?

0 个答案:

没有答案