angularjs – 如何告诉gulp-connect打开index.html,无论URL?
发布时间:2020-12-17 08:12:51 所属栏目:安全 来源:网络整理
导读:我有以下gulp任务: gulp.task('connect',function() { connect.server({ root: __dirname,livereload: true });}); 和以下Angular路线: angular.module("MyApp",["ngRoute"]).config(function($routeProvider,$locationProvider) { $locationProvider.html
我有以下gulp任务:
gulp.task('connect',function() { connect.server({ root: __dirname,livereload: true }); }); 和以下Angular路线: angular.module("MyApp",["ngRoute"]).config(function($routeProvider,$locationProvider) { $locationProvider.html5Mode(true); $routeProvider .when("/",{ controller: "DashboardCtrl",templateUrl: "templates/dashboard.html" }) .when("/advertiser",{ controller: "AdvertiserCtrl",templateUrl: "templates/advertiser.html" }) .otherwise({ redirectTo: "/" }); }); 当我访问/所有工作正常(仪表板出现)。 但是,访问/广告客户会导致“404 – 无法获取/广告客户”。 我的主要角色文件是index.html,它正确地打开/,但不是/广告商。 无论URL如何,我怎么能告诉Gulp打开index.html?
您可以使用中间件选项来使用
the connect-history-api-fallback middleware.一旦安装并需要回退,您可以这样添加:
gulp.task('connect',livereload: true,middleware: function(connect,opt) { return [ historyApiFallback ]; } }); }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |