gpt4 book ai didi

javascript - ASP MVC 4 bundle 未加载自定义 js 脚本

转载 作者:行者123 更新时间:2023-11-28 07:49:19 24 4
gpt4 key购买 nike

在我们的一个页面上,我们将大量的 jquery 塞进了一个脚本标签中。我试图通过将代码分成几个单独的 .js 文件并使用 ASP MVC 4 ScriptBundle 来清理一些内容。

但是,Chrome 只显示一个脚本正在加载,并且该脚本有一个奇怪的名称,看起来有点像 GUID。

enter image description here

如果我选择此脚本,我可以看到仅加载了包中的第一个 .js 文件。第二个文件完全丢失。

BundleConfig

public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/AgentTransmission").Include(
"~/Scripts/AgentTransmission/SetFields.js",
"~/Scripts/AgentTransmission/MarketingDivision.js"));
.
.
}
}

脚本文件夹的屏幕截图

enter image description here

.cshtml 创建文件( View )

@model MonetModelFromDb.Models.AgentTransmission

@{
ViewBag.Title = "Create new Agent";
}


<div>

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

<script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.1.js")" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
@Scripts.Render("~/bundles/AgentTransmission")

呈现的 HTML

<div>

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

<script src="/Scripts/jquery.maskedinput-1.3.1.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
<script src="/bundles/AgentTransmission?v=2D1TPLuuUcxrXmQ8AbdEoyTUVF8BEXja9e0nXKAzs9Q1"></script>

编辑

仅供引用,我也在 Debug模式下运行

最佳答案

当您“发布”项目并且选择的“配置”为“发布”时,系统会获取您的 bundle 并将它们组合成一个具有类似“GUID”名称的文件。如果您使用“调试”配置发布或构建项目,它会将 bundle 中的每个单独文件保留为 HTML 中的单独文件。

关于javascript - ASP MVC 4 bundle 未加载自定义 js 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27049220/

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