如何将两个数据放在标题中?
how to put two data in a title?
我想显示使用 API 检索数据的产品列表。
我用来显示数据的数组如下所示:
Array [
Object {
"amount": 2671.25,
"balance": 0,
"client_id": 1,
"created_at": "2020-05-06T17:42:26Z",
"discount": 0,
"discount_type": 0,
"id": 19,
"items": Array [
Object {
"cost": 2400,
"currency": "EUR",
"description": "",
"name": "Apple MacBook '' LED 500 Go SSD 32 Go",
"product_id": 5,
"quantity": 1,
"tax_rate_id": 1,
},
Object {
"cost": 54.25,
"currency": "EUR",
"description": "blablabla",
"product_id": 2,
"quantity": 5,
"tax_rate_id": 4,
},
],
"po_number": "",
"public_notes": "TEST 6 : Acomptes",
"quote_date": "2020-05-06",
"quote_number": "D0019",
"quote_status": 40,
"terms": "",
"updated_at": "2020-05-06T18:08:06Z",
},
有效,非常棒。但我想改进显示。
例如,当我展开我的 lilste 以获取详细信息时,我有价格。
<List.Item title={item.amount}/>
好的,很酷,但我想添加货币(欧元或其他货币)我该怎么做?我试过了,但没用:
<List.Item title={item.amount}{item.currency}/>
<List.Item title={item.amount} + {item.currency}/>
<List.Item title={item.amount} + '€'/>
<List.Item title='{item.amount} + €'/>
使用模板文字
Template literals are string literals allowing embedded expressions.
它采用以下形式:
`string text ${expression} string text`
所以你可以做类似的事情
<List.Item title={`${item.amount} ${item.currency}`} />
我想显示使用 API 检索数据的产品列表。
我用来显示数据的数组如下所示:
Array [
Object {
"amount": 2671.25,
"balance": 0,
"client_id": 1,
"created_at": "2020-05-06T17:42:26Z",
"discount": 0,
"discount_type": 0,
"id": 19,
"items": Array [
Object {
"cost": 2400,
"currency": "EUR",
"description": "",
"name": "Apple MacBook '' LED 500 Go SSD 32 Go",
"product_id": 5,
"quantity": 1,
"tax_rate_id": 1,
},
Object {
"cost": 54.25,
"currency": "EUR",
"description": "blablabla",
"product_id": 2,
"quantity": 5,
"tax_rate_id": 4,
},
],
"po_number": "",
"public_notes": "TEST 6 : Acomptes",
"quote_date": "2020-05-06",
"quote_number": "D0019",
"quote_status": 40,
"terms": "",
"updated_at": "2020-05-06T18:08:06Z",
},
有效,非常棒。但我想改进显示。 例如,当我展开我的 lilste 以获取详细信息时,我有价格。
<List.Item title={item.amount}/>
好的,很酷,但我想添加货币(欧元或其他货币)我该怎么做?我试过了,但没用:
<List.Item title={item.amount}{item.currency}/>
<List.Item title={item.amount} + {item.currency}/>
<List.Item title={item.amount} + '€'/>
<List.Item title='{item.amount} + €'/>
使用模板文字
Template literals are string literals allowing embedded expressions.
它采用以下形式:
`string text ${expression} string text`
所以你可以做类似的事情
<List.Item title={`${item.amount} ${item.currency}`} />