我已经实现了React-router 1.0,因为我实现了像
这样的路由器import React, { PropTypes, Component } from 'react';
import { Router, Route } from 'react-router';
import App from './App';
import RepoPage from './pages/RepoPage';
import UserPage from './pages/UserPage';
import TaskList from './pages/TaskList';
var data=[{path:'/:UserPage/:Id',PageUrl:'./pages/UserPage'},
{path:'/:RepoPage/:Id',PageUrl:'./pages/RepoPage'}
];
export default class Root extends Component {
static propTypes = {
history: PropTypes.object.isRequired
}
render() {
const { history } = this.props;
const ts=Object.keys(data).map(function(d){
return(
<Route path={data[d].path} component={require(data[d].PageUrl)} />
);
});
return (
<Router history={history}>
<Route path='/' component={TaskList}>
</Route>
<Route>
{ts}
</Route>
</Router>
)
}
}
正如你在我的代码中看到的那样,我正在创建一个变量ts并在渲染返回函数中使用该ts,如果我将使用它会给我警告,如
Webpack:依赖的请求是表达式