search

Home  >  Q&A  >  body text

angular.js - 用angular2-cli打包项目之后,跳转路由刷新会报404的错误

Aangular2项目用anguar2-cli下的ng build命令打包项目之后,运行dist文件夹中的静态index.html文件,第一次路由跳转没有问题,但是在跳转的路由中刷新页面的话,会返回404的错误。

GitHub代码链接:https://github.com/borysn/spr...

在主页面点击register 之后会正常跳转到注册页面,但是在注册页面下刷新的话,会返回404

不知道有没有其他人遇到过这种情况,有的话还烦请告知下解决办法。

天蓬老师天蓬老师2744 days ago632

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-05-15 17:12:28

    Adding {useHash:true} in the route can solve this problem

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 17:12:28

    Same question, I am also looking for this problem

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-15 17:12:28

    You can use Nginx to do a layer of routing transfer, first jump to the homepage, and then use the routing strategy to perform related rendering

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-15 17:12:28

    Whether dynamic parameters are set for the route? If so, this problem may occur. I am also working on solving it

    reply
    0
  • Cancelreply