我正在尝试使用 $locationProvider.html5Mode(true)
删除应用上的 # 标记。它删除了 #,但现在我的所有 View 都收到 404 错误
。
angular.module('myApp', ['ngRoute']).
config(['$routeProvider','$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/', { templateUrl: 'views/home.html', controller: 'homeCtrl' });
$routeProvider.when('/about', { templateUrl: 'views/about.html', controller: 'aboutCtrl' });
$locationProvider.html5Mode(true);
}]);
最佳答案
事实证明,如果有人使用 $locationProvider.html5Mode(true)
。您必须设置基本网址( <base href="/appFolder/" />
)... according to this answer
关于AngularJS:html5Mode(true)导致404错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21973802/