【问题标题】:Routing issue with AngularJS project using yeoman setup [duplicate]使用 yeoman 设置的 AngularJS 项目的路由问题 [重复]
【发布时间】:2016-12-14 10:49:45
【问题描述】:

我已经使用 yeoman 设置了一个新的 Angular 项目。 Angular 版本是 1.6.0。项目设置成功,但我遇到了路由问题

任务运行器 - Grunt

当我在本地运行项目时,我的本地页面将加载 URL

http://localhost:9000/#!/

我期待http://localhost:9000/#/

当点击关于链接浏览器被路由到

http://localhost:9000/#!/%23%2Fabout

期望:http://localhost:9000/#/about

当我点击主页链接浏览器被路由到

http://localhost:9000/#!/%23%2F

期望:http://localhost:9000/#/

可能是什么问题?我在使用 AngularJS 1.5.8 的其他系统中没有此类问题。

【问题讨论】:

    标签: angularjs yeoman angular-routing yeoman-generator-angular angularjs-1.6


    【解决方案1】:

    我用下面的代码解决了。你可以写在你的 app.js 文件中

     $locationProvider.hashPrefix('');
    

    【讨论】:

    猜你喜欢
    • 2014-11-26
    • 2019-10-24
    • 2016-11-09
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    相关资源
    最近更新 更多