我試圖基于兩個不同的數(shù)組創(chuàng)建多個列表。我有一個名為categoryList和termsList的數(shù)組。我想將基于屬性的術(shù)語列表分組到categoryList數(shù)組。const categoriesList = [ { name: 'Categories', slug: 'category' }, { name: 'Tags', slug: 'post_tag' }];和const termsList = [ { id: 1, taxonomy: 'category', name: 'First category' }, { id: 2, taxonomy: 'category', name: 'Second category' }, { id: 3, taxonomy: 'post_tag', name: 'First tag' }, { id: 4, taxonomy: 'post_tag', name: 'Second tag' }];類別列表中的屬性段始終與termsList中的分類屬性具有相同的值。我想要完成的是在React組件中做到這一點(diǎn):<h1>Categories</h1><ul> <li>First category</li> <li>Second category</li></ul><h1>Tags</h1><ul> <li>First tag</li> <li>Second tag</li></ul>我不知道該怎么做。一些幫助將不勝感激。謝謝!
需要幫助根據(jù)屬性將兩個數(shù)組與對象一起映射
慕尼黑8549860
2021-04-29 14:15:44