jsLint错误“无法设置未定义的属性“第一个"" [英] jsLint error "Cannot set property 'first' of undefined"

查看:45
本文介绍了jsLint错误“无法设置未定义的属性“第一个""的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此小提琴上运行jsLint.脚本运行了,但是当jsLint告诉我第7行字符18的问题:无法设置未定义的属性'first'"时,该告诉我什么?

Run jsLint on this fiddle. The script runs, but what is jsLint telling me when it says "Problem at line 7 character 18: Cannot set property 'first' of undefined"?

使用示例代码小提琴:

(function($) {
    $.fn.selectBox = function(data) {
        for (var x = 0; x < data.length; x++) {
        }

        return this;
    };
})(jQuery);

推荐答案

这是因为要在其中定义 for 语句的变量.在外面声明并解决!我修复了其他一些警告. http://jsfiddle.net/SXajC/87/

It's because you're defining the variable for the for statement inside of it. Declare it outside and solved!. I fixed a few other warnings. http://jsfiddle.net/SXajC/87/

这篇关于jsLint错误“无法设置未定义的属性“第一个""的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆