【发布时间】:2013-07-20 01:20:42
【问题描述】:
这是我的捆绑包:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Bootstrap/assets/js/jquery.js"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Bootstrap/assets/js/bootstrap-transition.js",
"~/Bootstrap/assets/js/bootstrap-alert.js",
"~/Bootstrap/assets/js/bootstrap-modal.js",
"~/Bootstrap/assets/js/bootstrap-dropdown.js",
"~/Bootstrap/assets/js/bootstrap-scrollspy.js",
"~/Bootstrap/assets/js/bootstrap-tab.js",
"~/Bootstrap/assets/js/bootstrap-tooltip.js",
"~/Bootstrap/assets/js/bootstrap-popover.js",
"~/Bootstrap/assets/js/bootstrap-button.js",
"~/Bootstrap/assets/js/bootstrap-collapse.js",
"~/Bootstrap/assets/js/bootstrap-carousel.js",
"~/Bootstrap/assets/js/bootstrap-typeahead.js",
"~/Bootstrap/assets/js/bootstrap-affix.js",
"~/Bootstrap/assets/js/application.js",
"~/Bootstrap/assets/js/bootstrap.js"
));
}
以下是我的 _Layout 页面的部分内容:
@Scripts.Render("~/bundles/bootstrap")
...
当我尝试运行此应用程序时,我收到类似这样的 js 错误
An Error has occurred in the script on this page
Object Expected
URL http://servername/AppName/bundles/bootstrap?v=asdjisdjsincdjijadosJISJDIS_idosd
这里问了一个类似的问题: Why is my CSS bundling not working with a bin deployed MVC4 app?
我尝试按照我引用的问题中的建议将此配置添加到我的 web.config 文件中
<modules runAllManagedModulesForAllRequests="true">
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>
我仍然遇到同样的错误。
如果有什么不清楚的地方请告诉我,我会详细说明。 谢谢
【问题讨论】:
-
你是在你的引导包之前渲染你的 jquery 包吗?它没有显示在您的代码中
-
你的包中的所有脚本都是第三方的吗?
-
没有。其中一些是我的。我通过关闭捆绑“解决”了这个问题(没有真正解决它)。我计划在项目结束时启用它并回到这个问题。
标签: asp.net-mvc razor bundle