📜  反应原生 sectionlist 过滤器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:16.760000             🧑  作者: Mango

代码示例1
searchFilterFunction(text) {

  if( text == undefined || text == '') {
    this.setState({
      sectiondata: this.arrayholder
    })
    return;
  }

  if (text.trim().length > 0) {
      var temp = []
      this.state.sectiondata.map((item) => {
            var dataItem = {};

            var title = item.title;
            var brandData = [];

            item.data.map((searchItem) => {
              let flatName =  searchItem.flat_name
                if (flatName.match(text)) {
                  brandData.push(searchItem);
                }
            })
            if (brandData.length > 0) {

            } else {
              return null;
            }
            dataItem.title = title;
            dataItem.data = brandData;
            temp.push(dataItem);
            this.setState({
              sectiondata: temp
            })
      })