angular - 更新到 Angular 11 时 BaseHref 在 scss 文件中不起作用
问题描述
我将我的 Angular 版本 profect 从 9 更新到 11,并且在使用 baseHref 编译项目时得到了问题。我已经从在 --base-href 之类的命令中设置 baseHref 更改为 angular.json 文件,并设置构建选项并设置“baseHref”:“/baseHref/”。当我检查浏览器请求时,我注意到从 scss 请求的图像不是使用 baseHref 请求的。我尝试设置 baseHref 和 deployUrl 但不起作用。
解决方案
在 index.html 文件更改
<base href="/">
至
<base href="./">
并尝试
ng build --prod --base-href ./
推荐阅读
- c++ - “Release”中的方法无法正常工作
- gremlin - Gremlin:如何检查添加边缘是否会导致循环
- html - Flask WTForms 验证器消息更改布局
- python - 请解决这个 TypeError: can only concatenate str (not "int") to str
- actionscript-3 - 如何向颜色选择器组件调色板添加更多颜色?(Adobe Flash/动画)
- sulu - Sulu:如何获取相关文章标签的url?
- awk - awk 中的匹配
- android - 在 android jetpack compose 中触发状态变化的事件
- ios - 在tableview中选择其中一个时如何禁用其他行?
- apache-superset - Apache SUPERSET 前端 - 在哪里编写拦截器,或者是否有一个在对所有 API 的每次请求之前调用的中心位置?