要实现的是json的筛选,类似于lambad表达式那样 查询,的功能
- find => (不适用)
只能返回第一个
var re = list.find(list=>list.ParentCode === '01');
等同于
var re =list.find((list) => { return list.ParentCode === '01' });
2 . (完美解决)
list.filter(function (item, index, self) {
if (item.ParentCode == code)
//return element;
//console.info(item);
$("#PT").append("<span class='PT' id='" + item.PlatformCode + "'>" + item.PlatformName + "</span><br/>");
})
- forEach
data.BU.forEach(function (item) {
$("#BU").append("<span class='BU' id='" + item.PlatformCode + "'>" + item.PlatformName + "</span><br/>");
});