我试图通过 fuse.js 向我的项目添加一个模糊搜索库。我包括以下几行,我得到一个构造函数错误,我试图重新安装保险丝,但我想知道错误可能出在哪里。
// TypeError: Fuse is not a constructor
var Fuse = require('fuse');
var options = { // list of options that need to be provided to fuse.js for search to occur
shouldSort: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
"title", // the keys that are searched
"description"
]
};
var fuse = new Fuse(posts, options); // "list" is the item array
var result = fuse.search(searchOptions.keywords); // search is conducted and result should be all matching JSON objects