【发布时间】:2015-12-31 06:36:46
【问题描述】:
我已安装所有正确的依赖项(此处为 react 和 react-router),并且我使用的是 React Router Github 页面中最基本的示例...但我无法摆脱此错误。
我的 React 路由器是 @ 0.13.3,而 React 也是 0.13.3。
这是我在 JSX 中的代码:
import "../css/master.scss";
import React from 'react';
import { Router, Route, Link } from 'react-router';
const App = React.createClass({
render() {
return (
<div>
<h1>App</h1>
<ul>
<li>
<Link to="about">About</Link>
</li>
</ul>
{this.props.children}
</div>
)
}
})
const About = React.createClass({
render() {
return <h3>About</h3>
}
})
const Contact = React.createClass({
render() {
return <h3>Contact</h3>
}
})
const routes = {
path: '/',
component: App,
childRoutes: [
{ path: 'about', component: About },
{ path: 'contact', component: Contact },
]
}
React.render(<Router routes={routes} />, document.getElementById('app'));
【问题讨论】:
标签: javascript reactjs react-router