对于加载的所有资产,HTML头部的base href似乎被忽略

对于加载的所有资产,HTML头部的base href似乎被忽略,html,browser,Html,Browser,也许我只是把整个想法搞错了,让我们看看这个。我有下面的HTML <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <base href="/xyz"> <link rel="stylesheet" href="

也许我只是把整个想法搞错了,让我们看看这个。我有下面的HTML

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <base href="/xyz"> 
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
    <app-root></app-root>
    <script src="runtime.js" defer=""></script><script src="polyfills.js" defer=""></script><script src="main.js" defer=""></script></body>
</html>

因此,服务器正在为/xyz路径中的所有文件提供服务通过获取基本URL(
http://localhost:8080/xyz
),删除路径中最后一个
/
之后的所有内容(为您提供
http://localhost:8080/
),然后追加新路径(
http://localhost:8080/styles.css


如果您想要
/xyz/styles.css
,那么您需要在基本路径的末尾添加一个
/

通过获取基本URL(
http://localhost:8080/xyz
),删除路径中最后一个
/
之后的所有内容(为您提供
http://localhost:8080/
)然后附加新路径(
http://localhost:8080/styles.css


如果您想要
/xyz/styles.css
,那么您需要在基本路径的末尾添加一个
/

好,这很有意义。在.my案例中,解决方案是将基本href设置为:。好,这很有意义。在.my案例中,解决方案是将基本href设置为:。
./server.js
./xyz/index.html
      styles.css
      .....