我收到错误:
未捕获的类型错误:无法读取未定义的属性“func”
然而我不知道为什么,我已经在谷歌上搜索了这个错误,然后用同样的错误给每个人发帖,但没有运气。谁能帮我吗?
我正在使用 react-router@3.0.2
索引.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import { Helmet } from 'react-helmet';
import Routes from './config/routes';
ReactDOM.render(
<div>
<Helmet>
<meta charSet='utf-8'/>
<title>Skelton</title>
<link rel='icon' href='images/favicon.png'/>
<link rel='stylesheet' href='style.css'/>
</Helmet>
<Router routes={Routes()} history={browserHistory}/>
</div>
, document.getElementById('root'));
路由.js
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import Example1 from '../pages/Example1';
export function routes() {
return (
<Route>
<Route path='/' component={Example1}/>
<IndexRoute component={Example1}/>
</Route>
);
}
export default routes;
Example1.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Example1 extends Component {
render() {
return (
<div>
<h1>Hello World! This is Example 1.</h1>
</div>
);
}
}
export default Example1;
最初我没有导入 PropTypes 因为我还不需要它。