【问题标题】:_ is undefined when using custom build lodash_ 在使用自定义构建 lodash 时未定义
【发布时间】:2017-10-09 11:25:34
【问题描述】:

我想在我的 Angular 应用程序中同时使用来自 lodash 的 ._get()._find()(从下划线中找到)。因为标准构建中没有默认值,所以我需要创建自定义构建。

通过 lodash cli 我运行了这个命令:lodash include=get,find。我已将生成的lodash.custom.js 包含到我的项目中。

但现在我得到了一个

ReferenceError: _ 未定义

我要使用的功能出错。

var matchedShopProduct = _.find($rootScope.currentShop.products, {_id: formattedProduct._id});

var value = _.get($scope.product.versions[i].modifiedProperties[0], property);

我想我在构建自定义构建时遗漏了一些东西,但我找不到什么。

【问题讨论】:

    标签: angularjs lodash


    【解决方案1】:

    通过在命令中添加exports=admin,global 解决了这个问题。 所以完整的命令是:

    lodash exports=amd,global include=get,find
    

    【讨论】:

      猜你喜欢
      • 2021-06-14
      • 1970-01-01
      • 2011-05-04
      • 1970-01-01
      • 2019-03-04
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 2015-08-18
      相关资源
      最近更新 更多