1
我試圖通過fuse.js添加一個模糊搜索庫到我的項目中。我包括以下幾行,我得到一個構造函數錯誤,我試圖重新安裝保險絲,但我想知道錯誤可能在哪裏。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
"decription"
]
};
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