我無法讓我的兩個陣列添加標簽和標簽描述。這一切似乎交織在一起。我將資料庫中的 JSON 資料匯入為“db”,所有這些資料都混在一起了。[![這是要查看的影像我不知道我是否正在解釋正確的新反應][1]][1]
"title_FQA": "What Statuses are Used for Projects?",
"tag_FQA": [ "Critical", "High", "Medium", "Low"],
"description_FQA": ["New products or functionality affecting customer usage with confirmed public release date within 30 days.",
"New products or functionality affecting customer usage with confirmed public release date within 90 days.",
"Enhances functionality or streamlines business processes, but is not required.",
"Modify appearance of screens, terminology, or customize base system applications for cosmetic purposes."
]
/////////////////////React Code /////////////////
<Grid paddingTop={3} container justifyContent="space-evenly">
{db.map((post) => {
return (
<Widget>
<Typography paddingBottom={3} variant="h3">
{post.title_FQA}
</Typography>
<Grid>
{post.tag_FQA}
{post.description_FQA}
</Grid>
</Widget>
</Grid>
[1]: https://i.stack.imgur.com/ym8u7.png
uj5u.com熱心網友回復:
如果我理解正確,您將需要指定每個標簽和描述陣列中要顯示的專案,例如:
{post.tag_FQA[0]}
{post.description_FQA[0]}
將回傳:
危急
影響客戶使用的新產品或功能在 30 天內確認公開發布日期。
{post.tag_FQA[1]}
{post.description_FQA[1]}
將回傳:
高的
影響客戶使用的新產品或功能在 90 天內確認公開發布日期。
為了更加自動化,添加另一個 map 函式來迭代每個帖子的標簽和描述陣列:
{db.map((post) => {
return (
<Widget>
<Typography paddingBottom={3} variant="h3">
{post.title_FQA}
</Typography>
{post.tag_FQA.map((tag, index) =>
<Grid>
{tag}
{post.description_FQA[index]}
</Grid>
)
}
</Widget>
)}
)}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/422886.html
標籤:
上一篇:使用JSONPath查找具有位于單獨屬性中的某個鍵的所有值
下一篇:保存對具有多個值的環境的回應
