【问题标题】:result of searching in arrays of objects在对象数组中搜索的结果
【发布时间】:2023-03-24 07:23:01
【问题描述】:

我正在使用 fuse.js 搜索对象数组,例如 http://fusejs.io/#searching-in-arrays-of-objects

它返回与标签匹配的整个项目。 我如何知道哪些标签匹配?

【问题讨论】:

    标签: javascript fuse.js


    【解决方案1】:

    设置选项时,将 verbose 设置为 true。这将使用匹配的键将匹配分数记录到控制台。

    const options = {
      verbose: true,
      shouldSort: true,
      threshold: 0.6,
      location: 0,
      distance: 100,
      maxPatternLength: 32,
      minMatchCharLength: 1,
      keys: [
        "title",
        "author.firstName"
      ]
    };
    const fuse = new Fuse(list, options);
    

    【讨论】:

      猜你喜欢
      • 2014-10-03
      • 2020-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      相关资源
      最近更新 更多