​jquery和underscore中这个each方法

  afterAjax: function(list) {
            if (list.length > 0) {
                _.each(list, function(v, i) {
                    if (v.flag == 0) {
                        v.flag = "否";
                    } else if (v.flag == 1) {
                        v.flag = "是";
                    };
                });
            }
            return list;
        },
    在这个里面的each方法便利这个list集合,回调函数中第一个参数不应该是索引吗??
    $.each(this.tableModel.model, function(i, v) {
                columns.push({
                    title: v.name,
                    data: v.code,
                    width: v.width,
                    "visible": v.visible === false ? false : true,
                    className: v.className,
                    "render": v.render,
                    "targets": i + startTarget + 1
                });
                that.column.push(v.code);

            });
      在这里面的回调函数第一个参数i应该是索引吧?


qq_小树_6
浏览 1369回答 1
1回答

橋本奈奈未

jquery的each的回调的第一个参数是索引没错
打开App,查看更多内容
随时随地看视频慕课网APP