[英]How to load lodash/fp in the browser?
I'm trying to use lodash/fp in a library written for the browser. 我试图在为浏览器编写的库中使用lodash / fp。 I'm using Webpack for packaging my library. 我正在使用Webpack打包我的库。
In my code, I currently load lodash/fp as follow (ES2015-style. I transpile it using Babel): 在我的代码中,我目前按如下方式加载lodash / fp(ES2015风格。我使用Babel进行转译):
import fp from "lodash/fp";
At runtime, from Chrome's debugger, I can notice the presence of the "standard" _
object at the top level, with all the usual, non curried methods. 在运行时,通过Chrome的调试器,我可以注意到所有常规的非咖喱方法都在顶层存在“标准” _
对象。 However the fp
object is not there and I can't access the fp-style methods. 但是fp
对象不存在,我无法访问fp样式的方法。
How can I make it working? 我该如何运作?
You can use the following to produce a global import 您可以使用以下内容进行全局导入
import fp from "lodash/fp";
window.fp = fp;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.