我不希望这张地图返回未定义我该怎么做?
var onCompareSelectedClick = function () {
var talentProfileInfoForAppliedResources = appliedResourcesEntries.map(function(res) {
console.log(res);
if(res.compareSelected == true) {
return data.getTalentProfileInfo(res.RES.RES_ID);
}
});
console.log(talentProfileInfoForAppliedResources);
this.openCompareTPDlg(talentProfileInfoForAppliedResources);
}.bind(this);
答案 0 :(得分:0)
只需在map
方法中添加if(res.compareSelected == true) {
return data.getTalentProfileInfo(res.RES.RES_ID);
} else {
return 'default_value';
}
语句,返回所需的值,例如:
<div class="w6">
<div style="display: table; background-color: brown;">
<div style="display: table-row" class="w12">
<span class="w2" style="display: table-cell; background-color: blue;"></span>
<!--<input type="text" class="w2"/>-->
<span class="w10">
<input type="text" />
</span>
</div>
</div>
</div>