for in 既可以遍历数组又可以遍历对象
typeShowClickEvent(index){
let typeName= this.state.typeNameList[index];
let obj = {};
if( typeName == "类型") {
}else {
obj.workOrderTypeString = typeName;
}
if( this.state.statusName == "状态" ) {
}else {
obj.workOrderStatusString = this.state.statusName;
}
if( this.state.city == "城市" ) {
}else {
obj.city = this.state.city;
}
let list = this.state.keepList;
//for in 遍历对象
for(var x in obj) {
// x 为对象的键,obj[x] 为键值
list = list.filter((item,index)=>{
//list 代表的是 代表一个数组
//item 代表数组中的每一项 ,是一个对象
//console.log("item",item);
return item[x] == obj[x];
})
}
if( list.length === 0){
this.props.history.push(`/noorder`);
}else {
this.setState({
type_show: false,
typeName: typeName,
contentList: list,
})
}
}