1

当我试图映射一组半大型数据时,我注意到它很慢..浏览器甚至会冻结几秒钟。我不确定它是来自 Jquery 地图还是淘汰赛

我认为这部分会变慢

model.Entries($.map(data.Entries, function (e, i) { return new  FieldFormatEntry(e.Name, e.HasTransformationList,e.Caption, e.HeaderName, e.Format, e.AcceptedFormats); })); 

这是代码

function FieldFormatEntry(name,transformationList,caption, headerName, format, acceptedFormats) {
    var self = this;
    self.Name = ko.observable(name);
    self.Caption = ko.observable(caption);
    self.HeaderName = ko.observable(headerName).extend({ required: true });
    self.Format = ko.observable(format).extend({ required: true });
    self.AcceptedFormats = ko.observableArray();
if (acceptedFormats !== null && acceptedFormats.length > 0)
    {
        var formats = ko.utils.arrayMap(acceptedFormats,function(item) {
            return item;
        });
        self.AcceptedFormats.push.apply(self.AcceptedFormats, formats);
}`enter code here`
    self.hasTransformationList = transformationList;
    self.hasAcceptedFormatsList = ko.computed(function () {
        return self.AcceptedFormats().length > 0;
    }, this);
}

function dataSet() {
    var self = this;
    self.Entries = ko.observableArray();
    self.showTip = ko.computed(function () {
        return (self.Entries().length > 1);
    }, this);
}



    function fillAndBindEntries(data) {
    var model = new dataSet();
    model.Entries($.map(data.Entries, function (e, i) { return new                       FieldFormatEntry(e.Name, e.HasTransformationList,e.Caption, e.HeaderName, e.Format, e.AcceptedFormats); }));
    ko.applyBindings(model);
}

有任何想法吗 ?我怎样才能提高性能

4

0 回答 0