react 配置的路由·不管用

路由配置如下:

https://img.mukewang.com/5c120bb70001da1506000394.jpg

用webpack-dev-server启动项目,
输入http://localhost:8080/#http://localhost:8080/都显示index,
输入http://localhost:8080/list提示Cannot GET /list,
http://localhost:8080/#/list也显示index 就是不会显示list 求解??????

婷婷同学_
浏览 685回答 1
1回答

心有法竹

history改browserHistoryrender(){&nbsp; &nbsp; return (&nbsp; &nbsp; &nbsp; &nbsp; <Router history={browserHistory}>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Route component={Index} path="/" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Route component={ComponentList} path="/list" />&nbsp; &nbsp; &nbsp; &nbsp; </Router>&nbsp; &nbsp; );}然后看看你的ComponentList 这个写的是否正确import React from 'react'export default class ComponentList extends React.Component {&nbsp; &nbsp; render() {&nbsp; &nbsp; &nbsp; &nbsp; return(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// your code&nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript