【发布时间】:2019-01-05 05:49:26
【问题描述】:
获取未捕获的类型错误:无法在我的 js 剔除文件中读取 null 的属性“映射”。我以前没有遇到过这个问题,对我来说看起来不错。我在这里遗漏了什么吗?
代码:
var ProcessorReviewerAssignmentViewModel = function (obj, token) {
obj = obj || {
PrsnPk: 0,
MaxCapacity: 0,
RemainCapacity: 0,
MinLoanAmt: 0,
MaxLoanAmt: 0,
MinAppraisalScore: 0,
MaxAppraisalScore: 0,
MinBpoScore: 0,
MaxBpoScore: 0,
AutoAssignEligible: false,
IsGetNext: false,
IsHighValueReady: false,
IsAppraiserScore: false,
ReviewTiers: [],
LoanClassifications: [],
AppraisalScoreRanges: [],
BPOAppraisalScoreRanges: [],
CurrentAppraiserScoreSelection: 0,
CurrentBPOAppraiserScoreSelection: 0,
//For Reviewer Services
ReviewerServices: []
}
var self = this;
//Value to determine if any of the values in Services are selected or not.
//So if any services aren't selected, we want to select ALL services, otherwise deselect ALL services.
var isUnChecked = ko.observableArray();
//set up anti-forgery tokens for ajax calls to server
$.ajaxSetup({
headers: { 'RequestVerificationToken': token }
});
//observables to mimic the server model
self.PrsnPk = ko.observable(obj.PrsnPk);
self.MaxCapacity = ko.observable(obj.MaxCapacity);
self.RemainCapacity = ko.observable(obj.RemainCapacity);
self.MinLoanAmt = ko.observable(obj.MinLoanAmt);
self.MaxLoanAmt = ko.observable(obj.MaxLoanAmt);
self.MinAppraisalScore = ko.observable(obj.MinAppraisalScore);
self.MaxAppraisalScore = ko.observable(obj.MaxAppraisalScore);
self.MinBpoScore = ko.observable(obj.MinBpoScore);
self.MaxBpoScore = ko.observable(obj.MaxBpoScore);
self.IsAppraiserScore = ko.observable(obj.IsAppraiserScore);
self.AutoAssignEligible = ko.observable(obj.AutoAssignEligible);
self.IsGetNext = ko.observable(obj.IsGetNext);
self.IsHighValueReady = ko.observable(obj.IsHighValueReady);
self.CurrentAppraiserScoreSelection = ko.observable(obj.CurrentAppraiserScoreSelection);
self.CurrentBPOAppraiserScoreSelection = ko.observable(obj.CurrentBPOAppraiserScoreSelection);
//AppInstId for Reviewer Services
self.AppInstId = ko.observable(obj.AppInstId);
//map arrays to mimic the server objects created from db
self.ReviewTiers = ko.observableArray(obj.ReviewTiers.map(function (element) {
return {
IsSelected: ko.observable(element.IsSelected),
Description: ko.observable(element.Description),
ReviewTierId: ko.observable(element.ReviewTierId)
}
}));
self.LoanClassifications = ko.observableArray(obj.LoanClassifications.map(function (element) {
return {
IsSelected: ko.observable(element.IsSelected),
SystemCode: ko.observable(element.SystemCode),
Description: ko.observable(element.Description)
}
}));
self.AppraisalScoreRanges = ko.observableArray(obj.AppraisalScoreRanges.map(function (element) {
return {
IsSelected: ko.observable(element.IsSelected),
Description: ko.observable(element.Description),
AppraisalScoreRangeID: ko.observable(element.AppraisalScoreRangeID)
}
}));
self.BPOAppraisalScoreRanges = ko.observableArray(obj.BPOAppraisalScoreRanges.map(function (element) {
return {
IsSelected: ko.observable(element.IsSelected),
Description: ko.observable(element.Description),
AppraisalScoreRangeID: ko.observable(element.AppraisalScoreRangeID)
}
}));
//Observable array to keep track of Reviewer services selected in view
**self.ReviewerServices = **ko.observableArray(obj.ReviewerServices.map(function (element)**** {
if (element.IsSelected === false) {
isUnChecked.push(element.IsSelected);
}
return {
ServiceId: ko.observable(element.ServiceId),
ServiceAliasDescription: ko.observable(element.ServiceAliasDescription),
IsSelected: ko.observable(element.IsSelected)
}
}));
错误发生在:
self.ReviewerServices = ko.observableArray(obj.ReviewerServices.map(function (element)
我认为这可能是因为加载此页面时 ReviewerServices 可能为空?
感谢您的意见。
【问题讨论】:
-
看起来可能需要添加到顶部的 obj 中?