var my_department = []; for (var i = 0; i < aggregations.all_outdept_name.buckets.length; i++) { if (aggregations.all_outdept_name.buckets[i].key == '') continue; var department_obj = {
value: aggregations.all_outdept_name.buckets[i].key, label: aggregations.all_outdept_name.buckets[i].key,
count: aggregations.all_outdept_name.buckets[i].doc_count
}
my_department.push(department_obj);
}
_this.department = my_department;
1 回答
慕森王
TA贡献1777条经验 获得超3个赞
continue的意思是跳过这轮循环,马上开始下轮循环。 在你的代码中,执行continue,那么if语句continue之后的都不执行了。 i++后执行新的一轮循环判断。
若想去掉,你就反着写呗,即满足xxx条件才执行if continue下面的语句
for (var i = 0; i < aggregations.all_outdept_name.buckets.length; i++) { if (!(aggregations.all_outdept_name.buckets[i].key == '')){ var department_obj = { value: aggregations.all_outdept_name.buckets[i].key, label: aggregations.all_outdept_name.buckets[i].key, count: aggregations.all_outdept_name.buckets[i].doc_count } my_department.push(department_obj); } }
添加回答
举报
0/150
提交
取消