简体   繁体   English

未捕获的参考错误:未定义滑块

[英]Uncaught reference error: slider is not defined

I'm trying to implement joss benner's fix as shown here . 我正在尝试实现joss benerner的修复程序,如下所示 I need to implement this code: 我需要实现以下代码:

slider.setOpts = function(opts) {
  for (var opt in opts) {
    vars[opt] = opts[opt];
  }
  slider.setup();
}

slider.getOpts = function() {
  return vars;
}

I've tried with this fiddle here , but I just get 我在这里尝试过这种提琴 ,但是我得到了

Uncaught ReferenceError: slider is not defined 

in the console. 在控制台中。 Not really what I'm doing. 并不是我在做什么。 The other commenters seem to be able to implement it no problem. 其他评论者似乎能够实现它。

Could someone also explain the meaning behind the code... what is slider ? 有人还能解释一下代码背后的含义吗?什么是slider A class? 一类? A function? 有功能吗? Where should I place the above code to add the .setOpts function? 我应该在上面的代码放在哪里添加.setOpts函数?

He wrote 他写了

I added these public methods to flexslider 我将这些公共方法添加到flexslider

To do so, you have to add those lines of code inside the jquery.flexslider.js -file and not in another js-file as you did in the fiddle. 为此,您必须将这些代码行添加到jquery.flexslider.js文件中,而不是像在小提琴中那样添加到另一个js文件中。 The error tells you what the problem is. 该错误告诉您问题出在哪里。 And in your case, slider is in fact not defined, because the slider -variable is being declared inside a codeblock of the jquery.flexslider.js which means, there is no reference to this variable outside of this block. 而在你的情况下, slider其实没有定义,因为slider -variable被的的代码块内声明jquery.flexslider.js这意味着,有此块之外这个变量没有提及。

The public methods start in line 426, so add your code there. 公共方法从第426行开始,因此在此处添加代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM