gpt4 book ai didi

angular - 在 Angular 2 应用程序( typescript )中使用 fuse.js

转载 作者:太空狗 更新时间:2023-10-29 17:36:06 25 4
gpt4 key购买 nike

我尝试在 angular2 应用程序中导入 fuse.js,但出现异常(未定义 Fuse)。我还检查了包中的定义文件 (index.d.ts)。

我的 typescript 类(class)是:

import 'fuse.js';

export class Myclass{

/**some code*/

public mySearchFunction(text, list, Opts){
let fuseSearch = new Fuse(list, Opts);
let fuseResults: any[] = fuseSearch.search(text);
return fuseResults
}

}

我也试过

import * as Fuse from 'fuse.js';

使用这个库的正确方法是什么?

最佳答案

打字是 8 天前才添加到项目中的。如果您查看来自 here 的最新 NPM 版本你会看到打字不包括在内。

如果您从 master 中提取包或获取文件 package.jsonindex.d.ts,那么您将能够通过 import * as Fuse from 'fuse.js';

使用包

查看控制台,我仍然收到错误 Cannot find module 'fuse.js',但它正在运行。不确定这是怎么回事。

2.6.1 版已于昨天推送到 NPM,它支持输入 - 参见 here

关于angular - 在 Angular 2 应用程序( typescript )中使用 fuse.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40834091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com