我想要转换旧的路由器代码。
我找不到解释如何更新旧路由器代码的地方。
如何使用“react-router”翻译下面的代码:“^ 4.2.0”?
来自app-client.js的示例代码:
var Router = require('react-router');
var Route = Router.Route;
var DefaultRoute = Router.DefaultRoute;
var routes = (
<Route handler={APP}>
<DefaultRoute handler={Audience} />
<Route name="speaker" path="speaker" handler={Speaker}></Route>
<Route name="board" path="board" handler={Board}></Route>
</Route>
);
Router.run(routes, function(handler) {
ReactDOM.render(<APP />, document.getElementById('react-container'));
});
APP.js的示例代码:
var Router = require('react-router');
var RouteHandler = Router.RouteHandler;
var APP = createReactClass({
render() {
return(
<div>
<Header title={this.state.title} status={this.state.status} />
<RouteHandler />
</div>
);
}
});
module.exports = APP;
答案 0 :(得分:0)