Lodash-'_'表示UMD全局,并且lodash.js不是模块错误 [英] Lodash - '_' refers to a UMD global and lodash.js is not a module errors
问题描述
如果我什么也不做,并添加了类型定义,则它适用于jquery,但lodash会得到一个
If I do nothing and add the type definition it works for jquery but lodash gets a
'_'表示UMD全局,但是当前文件是一个模块.考虑添加导入.
'_' referes to a UMD global, but the current file is a module. Consider adding an import instead.
如果我尝试通过导入调用的任意组合导入lodash,我会得到
If I try to import lodash with any combination of import call, I get
lodash.js不是一个模块
lodash.js is not a module
我试图通过提问 Angular(Angular 2)的另一个答案.我确实需要一个真实的答案,所以我重新发布自己的解决方案,希望有人最终能够帮助我理解这个问题.
I tried to get help by asking a question here and it was closed because there was another answer for Angular (Angular 2). I really need a real answer so I'm re-posting with my own solutions, hoping someone will eventually help me understand this problem.
在这种情况下,我是:
- 不使用任何类似Angular的框架
- 使用TypeScript
- 使用requirejs导入模块
- 使用Visual Studio
- 使用MVC5
推荐答案
我在全局类型定义文件(〜\ src \ typings.d.ts)中添加了以下代码来解决此问题.我正在使用Angular CLI 1.7
I added following code in my global typing definition file (~\src\typings.d.ts) to fix the problem. I'm using Angular CLI 1.7
// lodash global typing - begin
declare namespace _ {
}
// lodash global typing - end
这篇关于Lodash-'_'表示UMD全局,并且lodash.js不是模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!