路由配置如下:
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 這個寫的是否正確