如何在本机反应中为数组的每个元素分配相同的值。如何在本机反应中制作密钥对数组
Posted
技术标签:
【中文标题】如何在本机反应中为数组的每个元素分配相同的值。如何在本机反应中制作密钥对数组【英文标题】:How To assign same value To Each element of array in react native. How to Make key pair array in react native 【发布时间】:2021-11-23 02:10:37 【问题描述】:我有这样的数组数据
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 "]
现在我想为其中的每个元素分配相同的键。基本上我想制作关键对值。 请帮忙 。谢谢
【问题讨论】:
【参考方案1】:您可以使用Array.prototype.map
。
const directories = Subcategories.map(sub =>
return your_keyname: sub
)
【讨论】:
呜呜呜谢谢兄弟你做到了以上是关于如何在本机反应中为数组的每个元素分配相同的值。如何在本机反应中制作密钥对数组的主要内容,如果未能解决你的问题,请参考以下文章