admin管理员组文章数量:1417470
I've implemented fuse.js with this guide : / and the code :
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. 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?
I've implemented fuse.js with this guide : https://fusejs.io/ and the code :
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. 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?
-
simplest thing you can do in case api doesn't support limiting results is
result.slice(0,20)
– Code Maniac Commented Aug 25, 2019 at 14:25 - @CodeManiac thanks for your answer, if i use slice, it will slice after that all data has loaded. I want to just search 20 first items. – mmarket Commented Aug 25, 2019 at 14:38
1 Answer
Reset to default 6Fuse search has search SearchOpts
that has only param limit
so
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.
本文标签: javascriptlimit search results in fusejs vueStack Overflow
版权声明:本文标题:javascript - limit search results in fuse.js vue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745267611a2650696.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论