Lodash-'_'表示UMD全局,并且lodash.js不是模块错误 [英] Lodash - '_' refers to a UMD global and lodash.js is not a module errors

查看:1223
本文介绍了Lodash-'_'表示UMD全局,并且lodash.js不是模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我什么也不做,并添加了类型定义,则它适用于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.

在这种情况下,我是:

  1. 不使用任何类似Angular的框架
  2. 使用TypeScript
  3. 使用requirejs导入模块
  4. 使用Visual Studio
  5. 使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆