搜索框模糊查询
var cc = _this.state.virtualMachineArrayss.filter(function(item){ return item.name != text.name })
<Input placeholder="请输入要搜索的内容" onChange={this.handleChange.bind(this)} /> handleChange(e) { let val = e.target.value; let arr = this.props.list; let newArr = []; for (var i = 0; i < arr.length; i++) { for (var j = 0; j < arr[i].tags.length; j++) { if (arr[i].tags[j].indexOf(val) != -1) { newArr.push(arr[i]); break; } } } this.setState({ tabList: newArr }) }
if (this.selectedValue == '1') { this.searchItem = values; // var cc = this.listOfAllData.filter(function(item){ // return item.name != values // }) // this.listOfAllData = cc; if(values == ''){ // this.request(); this.listOfAllData = this.listOfAllDatas; }else{ let arr = this.listOfAllData; let newArr = []; for (var i = 0; i < arr.length; i++) { // for (var j = 0; j < arr[i].length; j++) { if (arr[i].name.indexOf(values) != -1) { newArr.push(arr[i]); // break; } // } } this.listOfAllData = newArr; } } else if (this.selectedValue == '2') { this.searchItems = values; if(values == ''){ // this.request(); this.listOfAllData = this.listOfAllDatas; }else{ let arr = this.listOfAllData; let newArr = []; for (var i = 0; i < arr.length; i++) { for (var j = 0; j < arr[i].keyList.length; j++) { if (arr[i].keyList[j].indexOf(values) != -1) { newArr.push(arr[i]); // break; } } } this.listOfAllData = newArr; } }