gpt4 book ai didi

Angular 5 - 动态基础引用导致重复加载包| block

转载 作者:太空狗 更新时间:2023-10-29 17:10:58 26 4
gpt4 key购买 nike

我在项目中使用的是 Angular 5.2 版本。我在 index.html 中动态设置基本引用以满足不同客户端的不同 URL。

应用主页 url 如下所示:-

http://example.com/client1/app/login
http://example.com/client2/app/login
http://example.com/client3/app/login

client1、client2 等是 IIS 中的虚拟目录

当我在浏览器中运行应用程序时,我可以从检查窗口中看到正在加载重复的 block 并导致应用程序页面变慢。

有一件事我观察到了重复 block 的网络请求 url。让我们说 script.xxxxxxxxxxxxxxxxxxxxxx.bundles.css。

第一个网络请求:-<强> https://example.com/client1/scripts.7186135389ca4b63fab4.bundle.js

第二个网络请求(重复):- https://example.com/scripts.7186135389ca4b63fab4.bundle.js

不需要第二个网络请求。而且我无法判断它是如何出现的。

enter image description here

Index.html 在我的项目中看起来像这样:-

<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Web</title>
<link href="/assets/Images/favicon.ico" rel="shortcut icon" type="image/x-icon">
<base id="baseHref" href="/">
<script>
(function () {
if (window.location.hostname !== 'localhost') document.getElementById('baseHref').href = "/" + window.location.pathname.split('/')[1] + "/";
})();
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<app-root></app-root>
</body>
</html>

请建议如何纠正此问题。

最佳答案

问题出在 ng 构建参数期间。

之前是

ng build --prod -e=dev --base-href=/Client1

在我将结尾/添加到 ng build 语句后,它工作正常。

ng build --prod -e=dev --base-href=/Client1/

重复的 Angular block 消失了。

关于Angular 5 - 动态基础引用导致重复加载包| block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53757931/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com