Sim*_*aur 14 angularjs gruntjs
在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)
];
}
}
},
Run Code Online (Sandbox Code Playgroud)
添加:
[require('connect-modrewrite')(['!(\\..+)$ / [L]'])].concat(
optBase.map(function(path){ return connect.static(path); })),
Run Code Online (Sandbox Code Playgroud)
确实用来为我工作启用html5模式,否则,我的路由不加载#!当我尝试通过浏览器重新加载时.
我确实在config中添加了基础href ='/'和html5Mode(true).还有什么我可以尝试的吗?为什么它真的会停止工作?
注意:事实证明我的URL中有一个点,并且connect-mod重写规则没有这样做.知道如何更改它并使其能够处理URL中的点?
尝试将其添加到配置块的根应用程序模块中。确保包含/注入 $locationProvider。
$locationProvider
.html5Mode({
enabled: true,
requireBase: false
})
.hashPrefix('!');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
304 次 |
| 最近记录: |