【发布时间】:2018-09-10 07:01:59
【问题描述】:
我尝试直接导入库
import * as hash from '../../../../node_modules/hashids';
并尝试了这段代码
let 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
任何提示将不胜感激! (此post的续篇)
【问题讨论】:
-
您是否尝试将
import * as hash from '../../../../node_modules/hashids';替换为require('hashids')? -
这样的,先生?要求('hashids');
-
如何访问这些方法?感谢您的回复!
-
在require之后,只需输入
declare var hashids:any;,然后作为文档使用。 -
它会抛出这个错误,ERROR ReferenceError: hashids is not defined。我想它确实有它的怪癖。感谢您再次回复先生!
标签: javascript angular typescript hashids