0
我打開HTML5樣式的URL(無 '#')的角像這樣渲染:角:HTML5風格的URL與無樣式
$locationProvider.html5Mode({
enabled: true,
requireBase: true
});
,並增加了基礎標籤:
<base href="/">
現在,當我導航到http://profile.myapp.com/show/1234
時,它呈現沒有應用任何樣式的頁面。
但是,當我使用帶'#'的URL時,頁面呈現正確。同樣,如果我禁用HTML5樣式的網址,頁面呈現正確。
我使用的UI路由器,配置有:
/** @ngInject */
function routerConfig($stateProvider, $urlRouterProvider) {
$stateProvider
.state('showProfile', {
url: '/show/:id',
templateUrl: 'app/profile/profile.html',
controller: 'ProfileController',
controllerAs: 'profileController'
});
$urlRouterProvider.otherwise('/show/1234');
}
CSS通過咕嘟咕嘟任務注入:
的CSS通過咕嘟咕嘟任務from this Yeoman Generator注入。
<!-- build:css({.tmp/serve,src}) styles/app.css -->
<!-- inject:css -->
<link rel="stylesheet" href="app/index.css">
<!-- endinject -->
<!-- endbuild -->
的任務看起來是這樣的:
VAR injectFiles = gulp.src([ path.join(conf.paths.src, '/app/**/*.scss'), path.join('!'+ conf.paths.src,'/app/index.scss') ],{read:false});
var injectOptions = {
transform: function(filePath) {
filePath = filePath.replace(conf.paths.src + '/app/', '');
return '@import "' + filePath + '";';
},
starttag: '// injector',
endtag: '// endinjector',
addRootSlash: false
};
問:
爲什麼會發生這種情況,是有什麼我可以做些什麼來解決這個問題,除了不使用HTML5的風格網址嗎?
*「爲什麼會發生這種情況」* - 因爲樣式表的URI不正確。但是,您沒有發佈如何將其包含在頁面中。 – dfsq
啊是的 - 這是新的東西。我已經添加了這些詳細信息@dfsq。它似乎是一個相對URL。 –