0

My array like:

[
{
    "id": 01,
    "no": "ABC",
    "offer": [
        {
            "offer_no": "ABC_01",
        },
        {
            "offer_no": "ABC_02",
        },
        {
           "offer_no": "ABC_05",
        }
    ]
},
{
    "id": 02,
    "no": "EFG",
    "offer": [
        {
            "offer_no": "EFG_01",
        },
    ]
}
]

Here i want to show:

no--------------offer

ABC    ABC_01

      ABC_02

      ABC_05

EFG    EFG_01

how can i show that in vue js?

i try before:

<table>
    <tbody>
        <template v-for="item in array_list">
            <template v-for="offer in item.offer">
                <tr>
                    <th>{{item.no}}</th>
                    <th>{{offer.offer_no}}</th>
                </tr>
            </template>
        </template>
    </tbody>
</table>

no--------------offer

ABC    ABC_01

ABC    ABC_02

ABC    ABC_05

EFG    EFG_01

but the result not my preferred

1
  • What have you tried so far? Commented Mar 12, 2019 at 9:59

2 Answers 2

2

Try the following code:

<table>
    <tbody>
        <template v-for="item in array_list">
            <template v-for="(offer,index) in item.offer">
                <tr>
                    <td><div v-show = "index ==0">{{item.no}}</div></td>
                    <td>{{offer.offer_no}}</td>
                </tr>
            </template>
        </template>
    </tbody>
</table>
Sign up to request clarification or add additional context in comments.

Comments

0

One way would be to use the index and only show the ABC/EFG-item when the index equals 0.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.