在角度路由时,页面刷新错误“HTTP错误404.0 - 未找到”即将到来

时间:2017-07-11 13:38:52

标签: angularjs

使用$ routeProvider,$ locationProvider处理角度路由。路由工作正常,但刷新页面“HTTP错误404.0 - 未找到”即将到来。请帮忙

标记

<!DOCTYPE html>
<html ng-app="myApp" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Routing</title>
    <script src="angular/angular.js"></script>
    <script src="angular/angular-route.min.js"></script>
    <script src="script/script.js"></script>
    <base href="/">
</head>
<body>
    <ul>
        <li><a href="home">Home</a></li>
        <li><a href="about">About</a></li>

        </ul>
    <div ng-view></div>
</body>
</html>

脚本

var myApp = angular.module("myApp", ['ngRoute']);
myApp.config(function ($routeProvider, $locationProvider) {
    $routeProvider
    .when("/", {
        templateUrl: "pages/home.html"
    })
.when("/about", {
    templateUrl: "pages/about.html"
})
    $locationProvider.html5Mode(true);

})

由于

0 个答案:

没有答案