如何在反应本机中为数组的每个元素分配相同的值。如何在 React Native 中制作密钥对数组
How To assign same value To Each element of array in react native. How to Make key pair array in react native
我有这样的数组数据
Subcategories:["Wooden Furniture","Office Furniture","Kitchen Furniture","Modular Office Furniture","Industrial Furniture","Steel Furniture","Living Room Furniture","|Storage and Display Furniture","Entryway Furniture","Inflatable Furniture","Patio Furniture & Accessories","Storage and Display Furniture"," Office & Commercial Furniture "]
现在我想为其中的每个元素分配相同的键。基本上我想制作密钥对值。
请帮忙 。谢谢
您可以使用 Array.prototype.map
.
const directories = Subcategories.map(sub => {
return { your_keyname: sub }
})
我有这样的数组数据
Subcategories:["Wooden Furniture","Office Furniture","Kitchen Furniture","Modular Office Furniture","Industrial Furniture","Steel Furniture","Living Room Furniture","|Storage and Display Furniture","Entryway Furniture","Inflatable Furniture","Patio Furniture & Accessories","Storage and Display Furniture"," Office & Commercial Furniture "]
现在我想为其中的每个元素分配相同的键。基本上我想制作密钥对值。 请帮忙 。谢谢
您可以使用 Array.prototype.map
.
const directories = Subcategories.map(sub => {
return { your_keyname: sub }
})