路由配置如下:
import React from 'react';
import ReactDom from 'react-dom';
import Index from './index';
import {Router,Route,hashHistory} from 'react-router';
import ComponentList from './components/list';
export default class Root extends React.Component{
render(){
return (
<Router history={hashHistory}>
<Route component={Index} path="/" />
<Route component={ComponentList} path="/list" />
</Router>
);
}
}
ReactDom.render(<Root/>,document.getElementById('example'));
用webpack-dev-server启动项目,
输入http://localhost:8080/#和http://localhost:8080/都显示index,
输入http://localhost:8080/list提示Cannot GET /list,
http://localhost:8080/#/list也显示index 就是不会显示list 求解??????
history改browserHistory
然后看看你的ComponentList 这个写的是否正确