这个是angular1.6默认给hash路由上添加了!(感叹号),导致出错,修改方法如下(添加配置,去掉默认前缀感叹号):

 
    angular.module('routingDemoApp',['ngRoute'])
    .config(['$routeProvider', function($routeProvider){
        $routeProvider
        .when('/',{template:'这是首页页面'})
        .when('/computers',{template:'这是电脑分类页面'})
        .when('/printers',{template:'这是打印机页面'})
        .otherwise({redirectTo:'/'});
    }])
    //添加如下配置
    .config(['$locationProvider', function($locationProvider) {
        $locationProvider.hashPrefix("");
    }]);
posted on 2017-12-28 11:01  Sharpest  阅读(210)  评论(0编辑  收藏  举报