ASP.NET MVC脚本包未呈现 [英] ASP.NET MVC Script bundle not rendered
本文介绍了ASP.NET MVC脚本包未呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经包含在 BundleConfig.cs
文件中的以下行:
bundles.Add(新ScriptBundle(〜/包/ jqueryajax)。包括(
〜/脚本/ jquery.unobtrusive-ajax.min.js));
然而,当我试图使其其他脚本中,它跳过了。
下面是我如何使脚本:
@ Scripts.Render(
〜/包/ jQuery的,
〜/包/ jQueryUI的
〜/包/ jqueryajax
〜/包/ jquerytree)
这是输出HTML中, jqueryajax 的省略包:
<脚本的src =/脚本/ jQuery的-1.9.1.js>< / SCRIPT>
<脚本的src =/脚本/ jQuery的-UI-1.10.2.js>< / SCRIPT>
<脚本的src =/脚本/ jquery.jstree.js>< / SCRIPT>
解决方案
我相信 ScriptBundle
试图再缩小文件时,调试=假
而不是使用现有的 .min.js
文件。有在web.config中的设置来影响如何工作的(集使用preMinifiedFiles 为的真正的)
<核心enableTracing =false的...>
< JS defaultMinifier =EdwardsJsMinifier使用preMinifiedFiles =真正的>
I've included the following line in the BundleConfig.cs
file:
bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include(
"~/Scripts/jquery.unobtrusive-ajax.min.js"));
However when I try to render it among other scripts, it's skipped.
Here is how I render the scripts:
@Scripts.Render(
"~/bundles/jquery",
"~/bundles/jqueryui",
"~/bundles/jqueryajax",
"~/bundles/jquerytree")
This is the output HTML, the jqueryajax bundle is omitted:
<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="/Scripts/jquery-ui-1.10.2.js"></script>
<script src="/Scripts/jquery.jstree.js"></script>
解决方案
I believe ScriptBundle
tries to minify the file when debug="false"
instead of using the existing .min.js
file. There is a setting in web.config to affect how this works (set usePreMinifiedFiles to true):
<core enableTracing="false" ...>
<js defaultMinifier="EdwardsJsMinifier" usePreMinifiedFiles="true">
这篇关于ASP.NET MVC脚本包未呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文