【问题标题】:Filter multiple lists using Fuse js at the same time同时使用 Fuse js 过滤多个列表
【发布时间】:2019-06-25 10:38:53
【问题描述】:

我有 3 个通过 API 生成的列表。我想使用 Fuse js 同时过滤这些列表。我检查了文档,找不到过滤多个列表的解决方案。

我不知道如何将 3 个不同的列表作为参数传递给 Fuse 方法。

this.state = {
  a: [],
  b: [],
  c: [],
}

filterVal = (e) =>{
  let searchOptions = {
    keys:['name'], //name is common key across all 3 lists
    includeMatches: true
  }

  var fuse = new Fuse(a,b,c, searchOptions); //not sure how pass 3 lists here
  var filteredResult = fuse.search(e.target.value); //passed the user input value
}

【问题讨论】:

    标签: reactjs input-filtering fuse.js


    【解决方案1】:

    您可以像这样合并列表:

    var fuse = new Fuse([...a, ...b, ...c] , searchOptions)
    

    【讨论】:

      猜你喜欢
      • 2021-12-17
      • 2013-08-02
      • 2020-10-12
      • 2017-08-03
      • 2019-06-19
      • 2015-02-09
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      相关资源
      最近更新 更多