在grunt文件中,livereload块如下所示:
livereload: {
options: {
open: true,
middleware: function(connect, options, middleware) {
var optBase = (typeof options.base === 'string') ? [options.base] : options.base;
return [
[require('connect-modrewrite')(['!(\\..+)$ / [L]'])].concat(
optBase.map(function(path) {
return connect.static(path);
})),
connect.static('.tmp'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect().use(
'/app/styles',
connect.static('./app/styles')
),
connect.static(appConfig.app)
];
}
}
},增加:
[require('connect-modrewrite')(['!(\\..+)$ / [L]'])].concat(
optBase.map(function(path){ return connect.static(path); })),曾经为我工作过启用html5模式,否则,我的路由不会加载没有#!当我试图通过浏览器重新加载时。
我在配置中添加了基本的href='/‘和html5Mode(true)。还有什么我可以试试的吗?为什么它真的停止工作了?
注释:原来我的URL中有一个点,而且没有被connect重写规则处理得那么好。知道如何改变它并使它能够处理URL中的点吗?
发布于 2017-10-11 18:58:23
尝试将其添加到配置块的根应用程序模块中。确保包括/注入$locationProvider。
$locationProvider
.html5Mode({
enabled: true,
requireBase: false
})
.hashPrefix('!');https://stackoverflow.com/questions/46387642
复制相似问题