你好,我不想在這樣的一個組件中回圈兩個不同的陣列
operationMep= [
{
"id": 15525205,
"type": "mise_en_prep",
"orderOperationSkus": [
{
"id": 24339529,
"orderSku": {
"id": 11747818,
"referenceMep": "MB0153",
"tax": 20,
"size": "M"
}
}
}
]
operationInvoice= [
{
"id": 16525205,
"type": "invoice",
"orderOperationSkus": [
{
"id": 24339529,
"orderSku": {
"id": 11747818,
"referenceInvoice": "MB0153"
}
}
}
]
<div v-for="itemMep in operationMep">
<my-template
v-for="itemVoice in operationInvoice"
:size="itemMep.size"
:invoice="itemVoice.referenceInvoice">
</my-template>
</div>
這樣做是可能的,因為我在這個組件中有 2 個回圈,如果操作發票為空,我想添加一個條件,只是回圈 operationMep。謝謝你
uj5u.com熱心網友回復:
如果我理解正確,您希望避免呈現嵌套的<my-template>if operationInvoiceis null。
您可以使用以下內容包裝嵌套v-for回圈v-if="operationInvoice":
<div v-for="itemMep in operationMep">
<template v-if="operationInvoice">
<my-template
v-for="itemVoice in operationInvoice"
:size="itemMep.size"
:invoice="itemVoice.referenceInvoice">
</my-template>
</template>
<!-- other markup here -->
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/344826.html
上一篇:Vuex狀態未設定為getter
下一篇:多選組件標簽作為編號
