【问题标题】:How to convert fat arrow AngularJS to coffeescript如何将胖箭头AngularJS转换为coffeescript
【发布时间】:2019-03-20 08:47:02
【问题描述】:

我在 AngularJS 中有代码并将其转换为将其写入 CoffeeScript 文件。

  let usedNames = _.map(existedEntries, entry => entry.name);

我需要帮助将粗箭头 (=>) 转换为 CoffeeScript。在编译上述代码时,我收到错误消息“不必要的胖箭头”。

我将不胜感激。

【问题讨论】:

    标签: angularjs coffeescript lodash


    【解决方案1】:

    哈鲁53

    hmmm.. 要将这段代码转换为咖啡脚本,只需将“胖箭头”更改为“苗条”即可。 :)。这就是你想要的?

    usedNames = _.map(existedEntries, (entry) ->
        entry.name
    )
    

    【讨论】:

    • 没问题哈鲁 ;)
    【解决方案2】:

    除了Mauricio Sipmann's answer

    您可以通过使用_.map() 速记迭代来避免回调函数:

    usedNames = _.map(existedEntries, 'name');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 2014-02-28
      • 1970-01-01
      • 2014-07-07
      • 1970-01-01
      • 2013-02-02
      相关资源
      最近更新 更多