Angular APP_BASE_HREF导致*.bundle.js脚本无法加载

Angular APP_BASE_HREF导致*.bundle.js脚本无法加载,angular,svg,webpack,angular-cli,Angular,Svg,Webpack,Angular Cli,我正在尝试让SVG渐变工作,从我在网上看到的情况来看,诀窍是使用APP\u BASE\u 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://localh

我正在尝试让SVG渐变工作,从我在网上看到的情况来看,诀窍是使用
APP\u BASE\u 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
  • 使用
    APP\u BASE\u HREF
    中断 导入如上所述,但修复了我的SVG
  • 这很有效 除了我的SVG渐变,其中
    url(#gradient)
    现在引用了错误的位置,并且找不到我的def
这是我的设置:

app.module.ts

import { CommonModule, APP_BASE_HREF } from '@angular/common';
并提供:

 providers: [
    {provide: APP_BASE_HREF, useValue: "/"},
  ],

您应该能够将
--deploy url=“/”
添加到命令行,使其生成脚本的正确路径

ng build --deploy-url="/"