The routing configuration is as follows:
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'));
Start the project with webpack-dev-server,
Enter http://localhost:8080/# and http://localhost:8080/ both display index,
Enter http://localhost:8080/ list prompts Cannot GET /list,
http://localhost:8080/#/list also displays index, but the list is not displayed. Any solution? ? ? ? ? ?
history changed to browserHistory
Then check whether your ComponentList is written correctly