为了账号安全,请及时绑定邮箱和手机立即绑定

react 配置的路由·不管用

react 配置的路由·不管用

婷婷同学_ 2018-11-22 14:14:28
路由配置如下:用webpack-dev-server启动项目,输入http://localhost:8080/#和http://localhost:8080/都显示index,输入http://localhost:8080/list提示Cannot GET /list,http://localhost:8080/#/list也显示index 就是不会显示list 求解??????

1 回答

?
心有法竹

TA贡献1866条经验 获得超5个赞

history改browserHistory

render(){

    return (

        <Router history={browserHistory}>

            <Route component={Index} path="/" />

            <Route component={ComponentList} path="/list" />

        </Router>

    );

}

然后看看你的ComponentList 这个写的是否正确

import React from 'react'

export default class ComponentList extends React.Component {

    render() {

        return(

           // your code

        )

  }

}


查看完整回答
反对 回复 2018-12-13

添加回答

代码语言

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号