breezejs:缩小脚本时出错

时间:2013-06-04 12:26:38

标签: asp.net-mvc-4 breeze bundling-and-minification

在缩小breezejs时我遇到了一个问题:

Error : Cannot get property « Validator » of a null reference  
(that's not the exact message but a translation of the original.)

当我尝试调用breeze.Validator时会发生这种情况,这意味着微风是未定义的。

现在,我依靠ASP.NET MVC捆绑机制来缩小文件breeze.debug.js以及我的应用程序中的所有其他脚本。

但是,如果不使用breeze.debug.js而是使用breeze.min.js(Breeze团队提供的那个),那么它可以正常工作。

这个问题可能是什么原因?

1 个答案:

答案 0 :(得分:3)

通过在发布模式下忽略breeze.debug.js文件并在调试模式下忽略breeze.min.js文件,我解决了这个问题:

bundles.IgnoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        bundles.IgnoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);

        bundles.Add(new ScriptBundle("~/bundles/breeze").Include("~/scripts/libs/breeze/breeze.debug.js")
            .Include("~/scripts/libs/breeze/breeze.min.js"));