gpt4 book ai didi

javascript - FlexSlider 未捕获类型错误和引用错误

转载 作者:行者123 更新时间:2023-11-28 19:31:24 25 4
gpt4 key购买 nike

我正在使用 FlexSlider 2.2.2,他下面的代码片段生成了两个 jQuery 错误

Uncaught TypeError: Cannot read property 'vars' of undefined Uncaught ReferenceError: SyntaxHighlighter is not defined

        jQuery(document).ready(function(){

// store the slider in a local variable
  var jQuerywindow = jQuery(window),
flexslider;

// tiny helper function to add breakpoints
function getGridSize() {
return (window.innerWidth < 600) ? 1 :
(window.innerWidth < 900) ? 3 : 3;
}

jQuery(function() {
SyntaxHighlighter.all();
});

jQuery('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
itemWidth: 290,
itemMargin: 0,
prevText: " ",
nextText: " ",
 minItems: getGridSize(), // use function to pull in initial value
      maxItems: getGridSize() // use function to pull in initial value
    });
// check grid size on resize event
jQuery(window).resize(function() {
var gridSize = getGridSize();

flexslider.vars.minItems = gridSize;
flexslider.vars.maxItems = gridSize;
});
});

编辑:突出显示错误以获得更好的可见性。

最佳答案

我无法重现语法荧光笔错误。但 flexslider 错误是因为您没有初始化 flexslider 变量。

工作演示:http://jsfiddle.net/lotusgodkk/nwjra/23/

    jQuery('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
itemWidth: 290,
itemMargin: 0,
prevText: " ",
nextText: " ",
minItems: getGridSize(),
maxItems: getGridSize(),
start: function (slider) {
flexslider = slider; //Initializing flexslider here.
}
});

您还可以看到这里没有出现语法高亮错误。

关于javascript - FlexSlider 未捕获类型错误和引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26690310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com