angularjs中的相对href路径与html5mode错误
relative href path goes wrong in angularjs with html5mode
我使用AngularJS来处理打开了html5mode的url。我还使用gullow角度生成器来构建项目。
情况:
index.js
$locationProvider
.html5Mode(true);
index.html
<!-- build:css({.tmp,src}) styles/app.css -->
<!-- inject:css -->
<link rel="stylesheet" href="app/index.css">
<!-- endinject -->
<!-- endbuild -->
<base href="/" />
问题
当url是example.com/somepage
时,index.css是从example.com/app/index.css
获得的,但当url是example.com/somepage/somedeeperpage
时,我刷新页面,index.css从example.com/somepage/app/index.css
获得
我希望能够在角度吞咽生成器中默认使用相对路径。
我必须在gulpfile中更改为base标记或index.css rel路径吗?
奇怪的是,相对路径在查找index.js 时运行良好
亲切问候
编辑:刚刚发现,如果我把标签放在注入样式之前,它就可以工作了。。。我的index.html现在看起来是这样的:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/">
<!-- build:css({.tmp/serve,src}) styles/app.css -->
<!-- inject:css -->
<!-- endinject -->
<!-- endbuild -->
</head>
上一个答案:
有同样的问题,通过在我的index.html文件中添加并更改gulp/inject.js:中的gulp-inject-config来实现这一点
之前:
var injectOptions = {
ignorePath: [options.src, options.tmp + '/serve'],
addRootSlash: false
};
之后:
var injectOptions = {
ignorePath: [options.src, options.tmp + '/serve']
};
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- CKFinder 3为所选文件返回错误的URL
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 铬:“;未捕获的语法错误:意外的标记:"
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- 相位器状态未捕获参考错误
- /undefined在我的404错误日志中多次出现
- angularjs中的相对href路径与html5mode错误
- AngularJS html5mode = 当我使用参数直接访问 url 时出现真正的错误
- html5mode 中的 AngularJS 路由错误
- Angularjs html5Mode(true) 页面重新加载错误与 Node.js 服务器
- 在AngularJS中启用html5Mode后,throw不会得到错误