我有2條路由,/
和,我已經測試了幾個。所有路由只呈現/
的主頁組件。React路由器只識別索引路由
當我嘗試的路徑不存在它承認罰款,並顯示警告 Warning: No route matches path "/example". Make sure you have <Route path="/example"> somewhere in your routes
App.js
import React from 'react';
import Router from 'react-router';
import { DefaultRoute, Link, Route, RouteHandler } from 'react-router';
import {Home, About} from './components/Main';
let routes = (
<Route name="home" path="/" handler={Home} >
<Route name="about" handler={About} />
</Route>
);
Router.run(routes, function (Handler) {
React.render(<Handler/>, document.body);
});
./components/Main
import React from 'react';
var Home = React.createClass({
render() {
return <div> this is the main component </div>
}
});
var About = React.createClass({
render(){
return <div>This is the about</div>
}
});
export default {
Home,About
};
我試過添加一個顯式路徑幾乎無濟於事。 <Route name="about" path="/about" handler={About} />
我已經偶然發現了這個stackoverflow Q,但在答案中沒有發現任何救贖。
任何人都可以闡明什麼可能是問題?