未被呈现的Bundle脚本文件。

时间:2021-01-02 16:46:40

Script file name:

脚本文件名称:

jquery.transit.min.js

The file is in the Scripts folder,

文件在Scripts文件夹中,

bundles.Add(new ScriptBundle("~/bundles/jquery")
       .Include("~/Scripts/jquery-{version}.js"));

bundles.Add(new ScriptBundle("~/bundles/jqueryui")
       .Include("~/Scripts/jquery-ui-{version}.js"));

bundles.Add(new ScriptBundle("~/bundles/jqueryval")
       .Include("~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*"));

bundles.Add(new ScriptBundle("~/bundles/jtransit")
       .Include("~/Scripts/jquery.transit*"));

In my View,

在我看来,

@Scripts.Render("~/bundles/jquery","~/bundles/jtransit")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")

Rendered HTML

呈现的HTML

<script src="/Scripts/jquery-1.8.3.js"></script>
<script src="/Scripts/jquery-ui-1.9.2.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>

jquery.transit.min.js doesn't get rendered. What am I missing?

jquery.transit.min。js不会呈现。我缺少什么?

7 个解决方案

#1


47  

I think it will be because you only have the .min version of your file.

我认为这是因为您只有.min版本的文件。

From your output I can see that you are running the debug build of your site. I guess as such the bundler is looking for a non-minified file.

从输出中可以看到,您正在运行站点的调试构建。我猜bundler正在寻找一个非缩小的文件。

If you were to do a Release build, then it would be bundled in OK.

如果你要做一个发布版本,那么它就会被绑定到OK中。

I'd suggest getting a non-minified version of the transit file and including that in your Scripts folder. Failing that, just make a copy of the minified version but without the .min in the filename.

我建议获取传输文件的非小型化版本,并将其包含在脚本文件夹中。如果做不到这一点,只需复制缩小的版本,但是文件名中没有.min。

#2


15  

Starting in MVC4, any minimized version of your JavaScript files or CSS files are ignored in Debug mode. As ngm suggests, you need to rename your file from,

从MVC4开始,在调试模式中,任何最小化的JavaScript文件或CSS文件都将被忽略。正如ngm建议的,您需要重新命名文件,

jquery.transit.min.js

to,

,

jquery.transit.js

Alternatively, you could modified the bundles.IgnoreList to allow minimized files to be rendered, as shown here.

或者,您可以修改包。IgnoreList允许呈现最小化的文件,如图所示。

#3


6  

I had to do this in Application_Start:

我必须在Application_Start中这样做:

BundleTable.EnableOptimizations = true;

#4


2  

In my case, I was attempting to use a script bundle and a style bundle with the same name.

在我的例子中,我试图使用一个脚本包和一个同名的样式包。

BundleConfig.cs:

BundleConfig.cs:

bundles.Add(new ScriptBundle("~/bundles/custom")
    .Include("~/Scripts/custom.js"));

bundles.Add(new StyleBundle("~/bundles/custom")
    .Include("~/CSS/custom.css"));

_Layout.cshtml:

_Layout.cshtml:

@Scripts.Render("~/bundles/custom")
@Styles.Render("~/bundles/custom")

This doesn't work. The last bundle added in the config survives, and @Scripts.Render("~/bundles/custom") just renders an empty line.

这并不工作。配置中添加的最后一个包仍然存在,@Scripts.Render(“~/bundle /custom”)只呈现空行。

I am using MVC 5.2.3.

我使用的是MVC 5.2.3。

#5


1  

If none of the above questions resolve your problem maybe you're missing this line

如果以上的问题都不能解决你的问题,那你可能就错过了这条线。

BundleConfig.RegisterBundles(BundleTable.Bundles);

from the Global.asax.cs file, if you're getting started with bundling take a look of this site: https://www.asp.net/mvc/overview/performance/bundling-and-minification

asax。cs文件,如果您正在开始打包,请查看这个站点:https://www.asp.net/mvc/overview/performance/bundling-and-minification

#6


0  

In my case Visual Studio 2013 just thought that bundling css files are missing, it showed yellow question mark over the filename in Solution Explorer.

在我的案例中,Visual Studio 2013仅仅认为没有绑定css文件,它在解决方案资源管理器的文件名上显示了黄色的问号。

Just double-click all these supposedly missing files and Visual Studio will find them, yellow question will mark dismiss and bundling will start working again like a charm.

只要双击所有这些可能丢失的文件,Visual Studio就会找到它们,黄色的问题将会消失,捆绑将重新开始工作,就像一种魅力。

#7


-1  

and make sure you're not using IE 8. Bundling failed for me in that browser but works fine in Chrome or Firefox.

确保你没有使用IE 8。在那个浏览器中,绑定失败了,但在Chrome或Firefox中运行良好。

#1


47  

I think it will be because you only have the .min version of your file.

我认为这是因为您只有.min版本的文件。

From your output I can see that you are running the debug build of your site. I guess as such the bundler is looking for a non-minified file.

从输出中可以看到,您正在运行站点的调试构建。我猜bundler正在寻找一个非缩小的文件。

If you were to do a Release build, then it would be bundled in OK.

如果你要做一个发布版本,那么它就会被绑定到OK中。

I'd suggest getting a non-minified version of the transit file and including that in your Scripts folder. Failing that, just make a copy of the minified version but without the .min in the filename.

我建议获取传输文件的非小型化版本,并将其包含在脚本文件夹中。如果做不到这一点,只需复制缩小的版本,但是文件名中没有.min。

#2


15  

Starting in MVC4, any minimized version of your JavaScript files or CSS files are ignored in Debug mode. As ngm suggests, you need to rename your file from,

从MVC4开始,在调试模式中,任何最小化的JavaScript文件或CSS文件都将被忽略。正如ngm建议的,您需要重新命名文件,

jquery.transit.min.js

to,

,

jquery.transit.js

Alternatively, you could modified the bundles.IgnoreList to allow minimized files to be rendered, as shown here.

或者,您可以修改包。IgnoreList允许呈现最小化的文件,如图所示。

#3


6  

I had to do this in Application_Start:

我必须在Application_Start中这样做:

BundleTable.EnableOptimizations = true;

#4


2  

In my case, I was attempting to use a script bundle and a style bundle with the same name.

在我的例子中,我试图使用一个脚本包和一个同名的样式包。

BundleConfig.cs:

BundleConfig.cs:

bundles.Add(new ScriptBundle("~/bundles/custom")
    .Include("~/Scripts/custom.js"));

bundles.Add(new StyleBundle("~/bundles/custom")
    .Include("~/CSS/custom.css"));

_Layout.cshtml:

_Layout.cshtml:

@Scripts.Render("~/bundles/custom")
@Styles.Render("~/bundles/custom")

This doesn't work. The last bundle added in the config survives, and @Scripts.Render("~/bundles/custom") just renders an empty line.

这并不工作。配置中添加的最后一个包仍然存在,@Scripts.Render(“~/bundle /custom”)只呈现空行。

I am using MVC 5.2.3.

我使用的是MVC 5.2.3。

#5


1  

If none of the above questions resolve your problem maybe you're missing this line

如果以上的问题都不能解决你的问题,那你可能就错过了这条线。

BundleConfig.RegisterBundles(BundleTable.Bundles);

from the Global.asax.cs file, if you're getting started with bundling take a look of this site: https://www.asp.net/mvc/overview/performance/bundling-and-minification

asax。cs文件,如果您正在开始打包,请查看这个站点:https://www.asp.net/mvc/overview/performance/bundling-and-minification

#6


0  

In my case Visual Studio 2013 just thought that bundling css files are missing, it showed yellow question mark over the filename in Solution Explorer.

在我的案例中,Visual Studio 2013仅仅认为没有绑定css文件,它在解决方案资源管理器的文件名上显示了黄色的问号。

Just double-click all these supposedly missing files and Visual Studio will find them, yellow question will mark dismiss and bundling will start working again like a charm.

只要双击所有这些可能丢失的文件,Visual Studio就会找到它们,黄色的问题将会消失,捆绑将重新开始工作,就像一种魅力。

#7


-1  

and make sure you're not using IE 8. Bundling failed for me in that browser but works fine in Chrome or Firefox.

确保你没有使用IE 8。在那个浏览器中,绑定失败了,但在Chrome或Firefox中运行良好。