MVC 母版页包含多个 JavaScript 文件
因此,我在 MVC 中有一个母版页,其母版页的头部部分包含以下代码:
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/jquery-ui-1.8.9.custom.css" rel="stylesheet" type="text/css" />
<link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.4.js" type="text/javascript" />
<script src="../../Scripts/grid.locale-en.js" type="text/javascript" />
<script src="../../Scripts/jquery.jqGrid.min.js" type="text/javascript" />
</head>
您可以看到最后三个文件是 JavaScript 文件。
现在,如果我运行此代码,则会包含我的 jquery-1.4.4.js,但不会包含与 jquery-1.4.4.js 位于同一文件夹中的 grid.locale-en.js 和 jquery.jqGrid.min.js !这是怎么回事?? MVC 是否很愚蠢,无法像第一个文件那样引用我的最后两个 javascript 文件?有趣的是,如果我用 jquery-1.4.4.js 注释掉 include,MVC 将引用第二行 grid.locale-en.js。所以看来 MVC 只能引用 javascript 的第一个包含行,无论它是什么,但不能引用此后的任何行。有人可以解释一下这个场景吗?
So I have a master page in MVC that has the following code in its Master Page's head section:
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/jquery-ui-1.8.9.custom.css" rel="stylesheet" type="text/css" />
<link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.4.js" type="text/javascript" />
<script src="../../Scripts/grid.locale-en.js" type="text/javascript" />
<script src="../../Scripts/jquery.jqGrid.min.js" type="text/javascript" />
</head>
You can see that the last three files are the JavaScript files.
Now if I run this code, my jquery-1.4.4.js is included, but grid.locale-en.js and jquery.jqGrid.min.js which are in the same folder as jquery-1.4.4.js are not! What's up with this?? Is MVC being dumb and can't reference my last two javascript files as it did with the first one? The interesting thing is that, if I comment out the include with jquery-1.4.4.js, MVC will reference grid.locale-en.js which is the second line. So it seems that MVC is able to only reference the first include line of the javascript which ever one it is, but not any line after that. Can someone please explain this scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要像这样关闭脚本标签
You need to close the script tag off like this