【发布时间】:2019-12-14 13:30:03
【问题描述】:
所以我想将此变量设置为数组中的所有对象,其中其类别具有特定关键字。 这就是我目前所拥有的
let tempMensProducts = tempClothingProducts
.filter(obj => obj.category.includes('Mens'))
export const clothingProducts = [
{
id: 1,
title: 'COMME DES GARCONS TEE',
img: 'img/product-1.png',
img2: 'img/product-1-1.png',
img3: 'img/product-1-2.png',
img4: 'img/product-1-3.png',
luxury: 'All Luxury items are inspected to verify authenticity',
price: 200,
info: ' COMME DES GARCONS PLAY BASIC LOGO TEE',
inCart: false,
count: 0,
total: 0,
fabric: '100% Cotton',
category: 'Mens Fashion'
}
]
【问题讨论】:
-
请添加一些预期的输入和输出。
-
嘿抱歉 ctrl k 只是搜索谷歌所以我必须在之后添加代码
-
你能添加一些示例数据吗
-
我没有对@TheGreenLightbulb 投反对票 - 请不要认为评论者是反对票的人。
-
@TheGreenLightbulb:兄弟放轻松,我刚刚恢复了我的反对意见。当没有看到样本和努力时,人们会否决这个问题。您添加了一些样本,现在一切正常。但很少有人会回来恢复它。但请记住,即使“男性”输入的类别是“女性时尚”,您标记为正确的答案也会返回 true
标签: javascript arrays reactjs object