我有 2 条路线,/
并且/about
我已经测试了更多路线。所有路由只渲染 home 组件,即/
.
当我尝试一条不存在的路线时,它会识别出该路线并显示警告
Warning: No route matches path "/example". Make sure you have <Route path="/example"> somewhere in your routes
应用程序.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);
});
./组件/主要
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,但没有找到答案。
任何人都可以阐明可能是什么问题吗?