jQuery 升级导致未捕获的类型错误

发布于 2025-01-11 17:42:24 字数 2237 浏览 0 评论 0原文

我正在努力将 jquery 从 2.1.4 更新到 3.6.0。看起来更新有效,但在我的网站上,highcharts 条形图消失了,我在谷歌上检查了“检查”,我得到: 在此处输入图像描述

Uncaught TypeError: jQuery.fn.chartTypeBar is not a function

at n.fn.init.jQuery.fn.hcCharts (scripts.js:37:66)

at HTMLDocument.<anonymous> (scripts.js:425:17)

at j (jquery.min.js:2:26925)

at Object.fireWith [as resolveWith] (jquery.min.js:2:27738)

at Function.ready (jquery.min.js:2:29532)

at HTMLDocument.I (jquery.min.js:2:29723)

当我删除 jQuery 更新时,一切正常(出现条形图) 。

以下是显示错误的代码:

! function (e) {

jQuery.fn.hcCharts = function () {

    Highcharts.setOptions({

        lang: {

            thousandsSep: ","

        }

    });

    var t = {

        lang: {

            thousandsSep: ","

        },

        title: {

            text: null

        },

        subtitle: {

            text: null

        },

        credits: {

            enabled: !1

        },

        exporting: {

            enabled: !1

        },

        chart: {

            spacing: [20, 20, 20, 20]

        },

        yAxis: {

            title: {

                style: {

                    color: "#a1a2a4",

                    fontSize: 13,

                    lineHeight: 17

                }

            }

        }

    };

   

    e(".chart-bar-h, .chart-bar-v").doesExist() && jQuery.fn.chartTypeBar(t), e(".chart-donut-1").doesExist() &&

        jQuery.fn.chartTypeDonut(t), e(".chart-area-1").doesExist() && jQuery.fn.chartTypeArea(t), e(".chart-line-1").doesExist()

        && jQuery.fn.chartTypeLine(t), e(".chart-negative-1").doesExist() && jQuery.fn.chartTypeNegative(t)

},

上面代码中的这一行在控制台上突出显示为错误: 在此处输入图片说明

chartTypeBar(t), e(".chart-donut-1").doesExist() &&

        jQuery.fn.chartTypeDonut(t), e(".chart-area-1").doesExist() && jQuery.fn.chartTypeArea(t), e(".chart-line-1").doesExist()

        && jQuery.fn.chartTypeLine(t), e(".chart-negative-1").doesExist() && jQuery.fn.chartTypeNegative(t)

I am working on updating jquery from 2.1.4 to 3.6.0. It looks like the update worked but on my website, the highcharts bar graph is gone, I checked "inspect" on google and I am getting:
enter image description here

Uncaught TypeError: jQuery.fn.chartTypeBar is not a function

at n.fn.init.jQuery.fn.hcCharts (scripts.js:37:66)

at HTMLDocument.<anonymous> (scripts.js:425:17)

at j (jquery.min.js:2:26925)

at Object.fireWith [as resolveWith] (jquery.min.js:2:27738)

at Function.ready (jquery.min.js:2:29532)

at HTMLDocument.I (jquery.min.js:2:29723)

When I remove the jQuery update, everything works fine again (bar graph appears).

Here is the code where the error is shown:

! function (e) {

jQuery.fn.hcCharts = function () {

    Highcharts.setOptions({

        lang: {

            thousandsSep: ","

        }

    });

    var t = {

        lang: {

            thousandsSep: ","

        },

        title: {

            text: null

        },

        subtitle: {

            text: null

        },

        credits: {

            enabled: !1

        },

        exporting: {

            enabled: !1

        },

        chart: {

            spacing: [20, 20, 20, 20]

        },

        yAxis: {

            title: {

                style: {

                    color: "#a1a2a4",

                    fontSize: 13,

                    lineHeight: 17

                }

            }

        }

    };

   

    e(".chart-bar-h, .chart-bar-v").doesExist() && jQuery.fn.chartTypeBar(t), e(".chart-donut-1").doesExist() &&

        jQuery.fn.chartTypeDonut(t), e(".chart-area-1").doesExist() && jQuery.fn.chartTypeArea(t), e(".chart-line-1").doesExist()

        && jQuery.fn.chartTypeLine(t), e(".chart-negative-1").doesExist() && jQuery.fn.chartTypeNegative(t)

},

This line from the code above is highlighted as an error on the console:
enter image description here

chartTypeBar(t), e(".chart-donut-1").doesExist() &&

        jQuery.fn.chartTypeDonut(t), e(".chart-area-1").doesExist() && jQuery.fn.chartTypeArea(t), e(".chart-line-1").doesExist()

        && jQuery.fn.chartTypeLine(t), e(".chart-negative-1").doesExist() && jQuery.fn.chartTypeNegative(t)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骷髅 2025-01-18 17:42:24

我知道出了什么问题了。我将 jQuery 升级脚本放在其他 10 个左右的高图表 javascript 后面......所以放在最后。我将 jQuery 升级移到了顶部,现在我的条形图出现了,升级成功了。

I figured out what was going wrong. I had placed the jQuery upgrade scripts after the other 10 or so high charts javascripts...so at the end. I moved the jQuery upgrade to the top and now my bar graphs appears and upgrade is a success.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文