Tablesorters addparse给出"undefined不是函数"

Cam*_*mmy 0 javascript jquery tablesorter

Tablesorter不是以某种方式接受.addParser.我收到错误"undefined is not a function".这是我的代码:

 $('mytable').tablesorter({
    sortList: [[0,0]],
    sortRestart: true,
    initialized: function(table) {
        var currentTable = $(table);
        var startcol = currentTable.data("startcol");
        if (startcol) {
            var sorting = [[startcol, 0]];
            currentTable.trigger("sorton", [sorting]);
        }
    },
    headers:
    {
        4: { sorter: 'customparse' },
        5: { sorter: 'customparse' }
    }
}).addParser({
    id: 'customparse',
    is: function (s) {
        return false;
    },
    format: function (s) {
        console.log(s);
        return s.replace(/\s+/g, '').replace(/,/g, '.');
    },
    type: 'numeric'
});
Run Code Online (Sandbox Code Playgroud)

我发现了一些其他相关的问题,无法找到我的问题..我很怀疑jQuery不包含两次.它没有addPareser工作正常甚至认为我使用的jQuery版本是1.11.但我尝试更新到2.1版但没有变化..

我发错了吗?我究竟做错了什么..

Poi*_*nty 5

要添加解析器,您需要使用$.tablesorter.addParser().您正在尝试从jQuery对象访问该方法.