Fuse.js 以键中的点在数组中搜索

Fuse.js to search in array with dot in keys

我在 Rest 端点上使用 fetch,它为我提供了一个对象数组。数组中的所有键中都有一个点。例如:{test.name:"test"}。我必须不断获取新的响应以获得更改,因此虽然我可以删除或替换点,但每次都需要一些 time/resources。有没有办法在 fuse.js?

中使用带点的键

我尝试了一些变体,但没有成功。

const fuse = new Fuse(this.state.test, {
    keys: ['test.name']
});

ps。我无法将 Rest 中的键更改为其外部

从 Fuse.js v6.3.0 开始,您可以通过点 (.) 数组符号提供路径来搜索嵌套值。因此,如果您的密钥中已经有一个点,您可以将其包装在一个数组中:

const fuse = new Fuse(this.state.test, {
  // `test.name` is the actual key, so wrap it in an array
  keys: [['test.name']]
});