简体   繁体   English

限制在 fuse.js vue 中的搜索结果

[英]limit search results in fuse.js vue

I've implemented fuse.js with this guide : https://fusejs.io/ and the code :我已经使用本指南实现了 fuse.js: https ://fusejs.io/ 和代码:

const Fuse = require("fuse.js");
  var fuse = new Fuse(this.$store.state.vendorProducts, options); 
  var result = fuse.search(this.itemTitle);

the result variable includes all the results of search operation.结果变量包括搜索操作的所有结果。
I want just first 20 results from result.我只想要结果的前 20 个结果。 I can slice the result array, but its too slow, because its loaded all data.我可以对结果数组进行切片,但它太慢了,因为它加载了所有数据。
How can i limit the search results by for example first 20 items?我如何限制搜索结果,例如前 20 个项目?

Fuse search has search SearchOpts that has only param limit so保险丝搜索具有搜索SearchOpts具有参数limit SearchOpts ,因此

const Fuse = require("fuse.js");
  var fuse = new Fuse(this.$store.state.vendorProducts, options); 
  var result = fuse.search(this.itemTitle, {limit: 20});

Found this feature from looking into source code.通过查看源代码发现此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM