我正在尝试使用lodash删除标签并仅使用value数组形成一个新数组。 我可以知道如何实现吗?
输入:
[
{label: "Campaign 3", value:3}
{label: "Campaign 1", value:1}
{label: "Campaign 4", value:2}
{label: "Campaign 6", value:5}
]
输出:
[3,1,2,5]
答案 0 :(得分:1)
您不需要任何第三方插件和库,例如 lodash 和 jquery ,只需将 javascript map 回调函数用作以上在评论部分完成。如果要使用lodash进行相同操作,请按照以下步骤进行操作。
var input = [
{label: "Campaign 3", value:3},
{label: "Campaign 1", value:1},
{label: "Campaign 4", value:2},
{label: "Campaign 6", value:5},
];
result = _.map(input, function(o) { return o.value; });
答案 1 :(得分:0)
不需要Lodash。您可以使用内置的JavaScript nout:TestEspressoFastlane macbook$ bundle exec fastlane mylane
[✔] ?
[18:56:18]: ------------------------------
[18:56:18]: --- Step: default_platform ---
[18:56:18]: ------------------------------
[18:56:18]: Driving the lane 'android mylane' ?
[18:56:18]: ---------------------
[18:56:18]: --- Step: mailgun ---
[18:56:18]: ---------------------
+------------------+----------------+
| Lane Context |
+------------------+----------------+
| DEFAULT_PLATFORM | android |
| PLATFORM_NAME | android |
| LANE_NAME | android mylane |
+------------------+----------------+
[18:56:25]: 400 Bad Request
+------+------------------+-------------+
| fastlane summary |
+------+------------------+-------------+
| Step | Action | Time (in s) |
+------+------------------+-------------+
| 1 | default_platform | 0 |
| ? | mailgun | 6 |
+------+------------------+-------------+
[18:56:25]: fastlane finished with errors
bundler: failed to load command: fastlane (/Users/macbook/.rbenv/versions/2.6.5/bin/fastlane)
函数:
map