Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
0x800a01b6-JavaScript运行时错误:对象不存在';t支持属性或方法';饼干';_Javascript_C#_Asp.net Mvc - Fatal编程技术网

0x800a01b6-JavaScript运行时错误:对象不存在';t支持属性或方法';饼干';

0x800a01b6-JavaScript运行时错误:对象不存在';t支持属性或方法';饼干';,javascript,c#,asp.net-mvc,Javascript,C#,Asp.net Mvc,我正在开发mvc web应用程序。我在包中添加了以下脚本 bundles.Add(new ScriptBundle("~/bundles/adminscripts").Include( "~/Scripts/jquery.js", "~/Scripts/bootstrap.js", "~/Scripts/jquery.dcjqaccordion.2.7.js",

我正在开发mvc web应用程序。我在包中添加了以下脚本

 bundles.Add(new ScriptBundle("~/bundles/adminscripts").Include(
                    "~/Scripts/jquery.js",
                    "~/Scripts/bootstrap.js",
                    "~/Scripts/jquery.dcjqaccordion.2.7.js",
                    "~/Scripts/jquery.scrollTo.min.js",
                    "~/Scripts/jquery.nicescroll.js",
                    "~/Scripts/jquery.sparkline.js",
                    "~/Scripts/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js",
                    "~/Scripts/owl.carousel.js",
                    "~/Scripts/jquery.customSelect.js",
                    "~/Scripts/respond.js",
                    "~/Scripts/slidebars.js",
                    "~/Scripts/common-scripts.js",
                    "~/Scripts/sparkline-chart.js",
                    "~/Scripts/easy-pie-chart.js",
                    "~/Scripts/count.js",
                    "~/Scripts/Main.js"));
当我运行这个站点时,它给了我这个错误

0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“cookie”

如果我将这些脚本添加到我的
\u LayOut.cshtml
上,那么所有脚本都可以正常工作,而不是将它们添加到包中。我添加了
BundleTable.EnableOptimizations=true在我的
Bundle.config
中。我不明白问题在哪里。有人能帮我解决这个问题吗?我从我的解决方案中搜索了整个
cookie
关键字,但没有找到任何东西。请看下面的截图

我已经使用nugget命令行包管理器升级了我的脚本。但我的问题仍然没有解决。我找到了引起问题的脚本

编辑 ~/Scripts/common Scripts.js这个脚本给了我一个错误

下面是脚本代码

/*---LEFT BAR ACCORDION----*/
$(function () {
    $('#nav-accordion').dcAccordion({
        eventType: 'click',
        autoClose: true,
        saveState: true,
        disableLink: true,
        speed: 'slow',
        showCount: false,
        autoExpand: true,
        //        cookie: 'dcjq-accordion-1',
        classExpand: 'dcjq-current-parent'
    });
});

// right slidebar
$(function () {
    $.slidebars();
});

var Script = function () {

    //    sidebar dropdown menu auto scrolling
    jQuery('#sidebar .sub-menu > a').click(function () {
        var o = ($(this).offset());
        diff = 250 - o.top;
        if (diff > 0)
            $("#sidebar").scrollTo("-=" + Math.abs(diff), 500);
        else
            $("#sidebar").scrollTo("+=" + Math.abs(diff), 500);
    });

    //    sidebar toggle
    $(function () {
        function responsiveView() {
            var wSize = $(window).width();
            if (wSize <= 768) {
                $('#container').addClass('sidebar-close');
                $('#sidebar > ul').hide();
            }

            if (wSize > 768) {
                $('#container').removeClass('sidebar-close');
                $('#sidebar > ul').show();
            }
        }
        $(window).on('load', responsiveView);
        $(window).on('resize', responsiveView);
    });

    $('.fa-bars').click(function () {
        if ($('#sidebar > ul').is(":visible") === true) {
            $('#main-content').css({
                'margin-left': '0px'
            });
            $('#sidebar').css({
                'margin-left': '-210px'
            });
            $('#sidebar > ul').hide();
            $("#container").addClass("sidebar-closed");
        } else {
            $('#main-content').css({
                'margin-left': '210px'
            });
            $('#sidebar > ul').show();
            $('#sidebar').css({
                'margin-left': '0'
            });
            $("#container").removeClass("sidebar-closed");
        }
    });

    // custom scrollbar
    $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '' });

    $("html").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '6', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', zindex: '1000' });

    // widget tools
    jQuery('.panel .tools .fa-chevron-down').click(function () {
        var el = jQuery(this).parents(".panel").children(".panel-body");
        if (jQuery(this).hasClass("fa-chevron-down")) {
            jQuery(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
            el.slideUp(200);
        } else {
            jQuery(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
            el.slideDown(200);
        }
    });

    // by default collapse widget
    //    $('.panel .tools .fa').click(function () {
    //        var el = $(this).parents(".panel").children(".panel-body");
    //        if ($(this).hasClass("fa-chevron-down")) {
    //            $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
    //            el.slideUp(200);
    //        } else {
    //            $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
    //            el.slideDown(200); }
    //    });

    jQuery('.panel .tools .fa-times').click(function () {
        jQuery(this).parents(".panel").parent().remove();
    });

    //    tool tips
    $('.tooltips').tooltip();

    //    popovers
    $('.popovers').popover();

    // custom bar chart
    if ($(".custom-bar-chart")) {
        $(".bar").each(function () {
            var i = $(this).find(".value").html();
            $(this).find(".value").html("");
            $(this).find(".value").animate({
                height: i
            }, 2000)
        })
    }
}();
/*---左栏手风琴----*/
$(函数(){
$('导航手风琴').d手风琴({
eventType:'单击',
自动关闭:是的,
saveState:是的,
disableLink:对,
速度:“慢”,
showCount:错,
自动展开:对,
//曲奇:“dcjq-accordion-1”,
classExpand:'dcjq当前父级'
});
});
//右滑块
$(函数(){
$.slidebar();
});
var脚本=函数(){
//侧边栏下拉菜单自动滚动
jQuery(“#侧边栏.子菜单>a”)。单击(函数(){
var o=($(this.offset());
差异=250-o.顶部;
如果(差异>0)
$(“#边栏”).scrollTo(“-=”+Math.abs(diff),500);
其他的
$(“#边栏”)。滚动到(“+=”+Math.abs(diff),500);
});
//侧边栏切换
$(函数(){
函数响应视图(){
var wSize=$(window.width();
如果(wSize 768){
$(“#容器”).removeClass('sidebar-close');
$('#侧边栏>ul').show();
}
}
$(窗口).on('load',responsiveView);
$(窗口).on('resize',responsiveView);
});
$('.fa条')。单击(函数(){
如果($('#边栏>ul')为(“:可见”)==true){
$(“#主要内容”).css({
“左边距”:“0px”
});
$(“#侧边栏”).css({
“左边距”:“-210px”
});
$('#侧边栏>ul').hide();
$(“#容器”).addClass(“侧栏关闭”);
}否则{
$(“#主要内容”).css({
“左边距”:“210px”
});
$('#侧边栏>ul').show();
$(“#侧边栏”).css({
“左边距”:“0”
});
$(“#容器”).removeClass(“侧栏关闭”);
}
});
//自定义滚动条
$(“#边栏”).niceScroll({styler:“fb”,cursorcolor:“e8403f”,cursorwidth:“3”,cursorborderradius:“10px”,背景:“#404040”,spacebarenabled:false,cursorborder:”});
$(“html”).niceScroll({styler:“fb”,cursorcolor:“e8403f”,cursorwidth:'6',cursorborderradius:'10px',background:'404040',spacebarenabled:false,cursorborder:'',zindex:'1000');
//小部件工具
jQuery('.panel.tools.fa chevron down')。单击(函数(){
var el=jQuery(this).parents(“.panel”).children(.panel主体”);
if(jQuery(this).hasClass(“fa chevron down”)){
jQuery(this).removeClass(“fa-chevron-down”).addClass(“fa-chevron-up”);
el.slideUp(200);
}否则{
jQuery(this).removeClass(“fa-chevron-up”).addClass(“fa-chevron-down”);
el.向下滑动(200);
}
});
//默认情况下,折叠小部件
//$('.panel.tools.fa')。单击(函数(){
//var el=$(this).parents(.panel”).children(.panel主体);
//如果($(此).hasClass(“fa V形向下”)){
//$(此).removeClass(“fa V形向下”).addClass(“fa V形向上”);
//el.slideUp(200);
//}其他{
//$(此).removeClass(“fa V形向上”).addClass(“fa V形向下”);
//el.slideDown(200);}
//    });
jQuery('.panel.tools.fa times')。单击(函数(){
jQuery(this).parents(“.panel”).parent().remove();
});
//工具提示
$('.tooltips').tooltip();
//爆米花
$('.popover').popover();
//自定义条形图
如果($(“.custom条形图”)){
$(“.bar”)。每个(函数(){
var i=$(this.find(“.value”).html();
$(this.find(“.value”).html(“”);
$(this.find(“.value”).animate({
身高:i
}, 2000)
})
}
}();

查看该dcjqAccordian的源代码,它尝试调用
$.cookie
保存其状态。您需要添加jQuery.Cookie作为脚本,才能使其正常工作:或

因此,您的包将类似于:

bundles.Add(new ScriptBundle("~/bundles/adminscripts").Include(
                    "~/Scripts/jquery.js",
                    "~/Scripts/jquery.cookie.*",
                    "~/Scripts/bootstrap.js",
                    "~/Scripts/jquery.dcjqaccordion.2.7.js",
                    ... etc.
另一方面,我会避免使用普通的“jquery.js”引用;假设您使用的是NuGet软件包,您通常会使用:

bundles.Add(new ScriptBundle("~/bundles/adminscripts").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/jquery.cookie.*",
                    "~/Scripts/bootstrap.js",
                    "~/Scripts/jquery.dcjqaccordion.2.7.js",
                    ... etc.

我猜在捆绑过程中脚本正在缩小,缩小的变量正在相互覆盖。@MikeLoffland感谢您的回复。但是我从脚本中删除了
.min
。@MikeLoffland我从我的解决方案中搜索了
cookie
关键字完整,但没有找到任何内容。如果您将BundleTable.EnableOptimizations设置为false,并且没有得到错误。。。它证明了缩小是原因。Scripts/jquery.scrollTo.min.js谢谢回复。我已将此脚本添加到解决方案中。现在,它在
幻灯片中给了我错误。它正在工作。我的错误。我在
slidebar.js
文件中输入了错误的路径非常感谢您的帮助:)