[英]Nested conditional rendering in jsx React
我試圖在 jsx 本身中有一個嵌套的 if 條件。 這是我的代碼示例:
{this.props.customerInformation?
<Descriptions title="Customer Information" bordered>
{this.props.customerInformation.customer_status.label}</Descriptions.Item>
</Descriptions>
:
<Button> Create a new customer </Button>
}
我試圖做的是在頂級條件中添加另一個條件,看起來像這樣:
{this.props.customerInformation?
<Descriptions title="Customer Information" bordered>
<Descriptions.Item>
{this.props.customerInformation.customer_status.label}
</Descriptions.Item>
<Description.Item>
{this.props.customerInformation.poc?
<Descriptions title="poc" >
{this.props.customerInformation.poc}
<Descriptions.Item>
</Descriptions>
:
<Button> Create a new customer </Button>
}
添加括號來包裝您的代碼。
{this.props.customerInformation?
(<Descriptions title="Customer Information" bordered>
{this.props.customerInformation.customer_status.label}
</Descriptions.Item>
</Descriptions>)
:
(<Button> Create a new customer </Button>)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.