【发布时间】:2017-08-29 02:32:12
【问题描述】:
我正在尝试使 SVG 渐变工作,从我在网上看到的情况来看,诀窍是使用 APP_BASE_HREF 而不是定义 <base href="/">。这确实解决了这个问题,但它也创造了一个新问题。如果我深入一层/home/test,bundle.js 脚本将无法加载。
错误
GET http://localhost:4200/home/inline.bundle.js
goals:47 GET http://localhost:4200/home/polyfills.bundle.js
goals:47 GET http://localhost:4200/home/styles.bundle.js
goals:47 GET http://localhost:4200/home/vendor.bundle.js
goals:47 GET http://localhost:4200/home/main.bundle.js
goals:47 GET http://localhost:4200/home/inline.bundle.js
goals:47 GET http://localhost:4200/home/polyfills.bundle.js
goals:47 GET http://localhost:4200/home/styles.bundle.js
goals:47 GET http://localhost:4200/home/vendor.bundle.js
goals:47 GET http://localhost:4200/home/main.bundle.js
它正在寻找http://localhost:4200/main.bundle.js,但现在基本引用不正确,它将其更改为/home/main.bundle.js
设置的正确方法是什么?
- 我不想使用 HTML5 #locations
- 使用
APP_BASE_HREF中断 如上所述的导入,但修复了我的 SVG -
<base href="/">这个工作 除了我的 SVG 渐变,url(#gradient)现在引用了错误的位置并且无法找到我的 defs。
这是我的设置:
app.module.ts
import { CommonModule, APP_BASE_HREF } from '@angular/common';
并提供:
providers: [
{provide: APP_BASE_HREF, useValue: "/"},
],
【问题讨论】:
标签: angular svg webpack angular-cli