React router 传参不成功


我根据 react-router 官方文档 创建了路由


 import React from 'react';
import Router from 'react-router';

import Maintain from './components/App/Maintain';
import MaintainDetail from './components/App/MaintainDetail';

let Route = Router.Route;
let RouteHandler = Router.RouteHandler;

let routes = (
  <Route handler={App}>
      <Route path="maintain" handler={Maintain}/>
      <Route path="maintain/detail:id" handler={MaintainDetail}/>
  </Route>
);

let App = React.createClass({
  render () {
    return (
        <RouteHandler/>
    )
  }
});


Router.run(routes, Router.HashLocation, (Root) => {
  React.render(<Root />, document.getElementById('app'));
});

然后当我访问
/#/maintain/detail/123
时我得到的是空白页面以及
Warning: No route matches path "/maintain/detail/123". Make sure you have <Route path="/maintain/detail/123"> somewhere in your routes

react.js JavaScript

YYMoon 9 years, 5 months ago

maintain/detail/:id

CROWj answered 9 years, 5 months ago

Your Answer