This是我所见过的唯一成角度的端口。事实是,它不再维护,并且没有在GitHub的read.me上提供快速入门教程。我还考虑过直接使用hashids.js,但是我对遵循的步骤感到困惑。
所以我想知道是否有人在角度上使用了它,以及他们是如何做到的。谢谢! :)
更新
我尝试导入上述ng端口,但出现此错误
./ node_modules / ng2-hashids / index.ts中的错误 模块构建失败:错误:C:\ Users \ FireCuda \ Projects \ angular \ InformationAndEve Ty中缺少ntSystem \ stiGoDashboard \ node_modules \ ng2-hashids \ index.ts peScript编译。请通过“文件”确保它在您的tsconfig中或 “包含”属性。 丢失的文件似乎是第三方库的一部分。已发布库中的TS文件通常是库包装不良的标志。请在图书馆资料库中打开一个问题,以提醒作者并要求他们打包图书馆 使用Angular封装格式。 在AngularCompilerPlugin.getCompiledFile(C:\ Users \ FireCuda \ Projects \ angular \ InformationAndEventSystem \ stiGoDashboard \ node_modules \ @ngtools \ webpack \ src \ angu lar_compiler_plugin.js:740:23) 然后在plugin.done.then(C:\ Users \ FireCuda \ Projects \ angular \ InformationAndEventS ystem \ stiGoDashboard \ node_modules \ @ngtools \ webpack \ src \ loader.js:41:31) 在 在process._tickCallback(internal / process / next_tick.js:188:7)
第二次更新
我尝试直接导入库
import * as hash from '../../../../node_modules/hashids';
并尝试了此代码 让id = hash.encode(this.studentDocument.student_id_number); console.log(id);
可惜它抛出了这个错误。
_node_modules_hashids__WEBPACK_IMPORTED_MODULE_2__.encode is not a function
我什至尝试过
declare var hash:any;
但是它抛出了这个错误
hash is not defined
似乎所有人都需要使用它之前,它需要进行更新。 任何有关如何使用纯js库的技巧,尤其是这个库,将不胜感激!