我有一個要求,當我點擊一個按鈕時,我應該使用 react bootstrap 顯示一個模式彈出框。
But the value is not displaying inside modal body.
when I puted log, in the console it is printing all the values. But the same value I want to try to print on the modal body is not printing.
這是示例代碼 `function MyVerticallyCenteredModal(props) {
回傳 (
<Modal scrollable={true}
{...props}
size="lg"
aria-labelledby="contained-modal-title-vcenter"
centered
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter">
Order Id - {props.order.orderId}
</Modal.Title>
</Modal.Header>
<Modal.Body>
<table>
<tbody>
{
props.order.foods.map((food,id)=>{
console.log(food);
<tr>
<td>{food}</td>
</tr>
})
}
</tbody>
</table>
</Modal.Body>
<Modal.Footer>
{/* <Button onClick={props.onHide}>Close</Button> */}
</Modal.Footer>
</Modal>
); }`
誰能幫我解決這個問題
Thanks in advance.
uj5u.com熱心網友回復:
您沒有在代碼中使用 return,這就是您的地圖不回傳任何內容的原因,試試這個,
<tbody>
{
props.order.foods.map((food,id)=>{
console.log(food);
return (
<tr>
<td>{food}</td>
</tr>
)
})
}
</tbody>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/457322.html
標籤:javascript 反应 反应引导
