本文介绍了JS Lint:"_ fnGetTrNodes"中意外悬挂了"_"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

$.extend($.fn.dataTableExt.afnSortData, {
    'dom-text': function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push(this.value);
        });
        return aData;
    },
    'dom-data-rk': function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push($(this).attr('data-rk'));
        });
        return aData;
    }
});

我使用了JSLint,但出现了错误:

I used JSLint and it came up with an error:

Warning 21  JS Lint: Unexpected dangling '_' in '_fnGetTrNodes'.

有人可以解释这是什么意思吗?我根本不理解错误消息:-(

Can someone explain what this means? I don't understand the error message at all :-(

推荐答案

JSLint根本不喜欢标识符以下划线字符开头.更改标识符,警告将消失,或在文件顶部添加以下指令:

JSLint simply doesn't like identifiers to begin with an underscore character. Change the identifier and the warning will go away, or add the following directive to the top of the file:

/*jslint nomen: true */

之所以不喜欢它们,是因为人们经常使用它来表示私有"变量,但实际上并没有改变变量的行为.

The reason it doesn't like them is that people often use it to indicate a "private" variable, but doesn't actually change the behaviour of the variable.

这篇关于JS Lint:"_ fnGetTrNodes"中意外悬挂了"_"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:48