0

This is my code.

<b-tbody v-for="(item, index) in list" :key="index>
 <b-tr>
  <b-td></b-td>
 </b-tr>
 <b-tr v-for="(item2, index) in list2" :key="index">
  <b-td></b-td>
 </b-tr>
</b-tbody>

I think first loop is going well, but next one doesn't work. what can i do ?

1
  • 1
    What do you mean it doesn't work? Any error? Have you debugged your code (i.e. does list2 exists and have items)? Do you actually display something because your tags are empty... Commented Jun 25, 2021 at 7:18

3 Answers 3

1

You are missing the closing quotation marks at the first :key="index.

Do you get anything if you run:

<b-tbody v-for="(item, index) in list" :key="index">
 <b-tr>
  <b-td>{{ item }}</b-td>
 </b-tr>
 <b-tr v-for="(item2, index) in list2" :key="index">
  <b-td>{{ item2 }}</b-td>
 </b-tr>
</b-tbody>

... depending of course, how your lists are structured ... but you should now see something, where {{ item }} is.

Sign up to request clarification or add additional context in comments.

Comments

0

The second loop actually works (d, e, f) but what are you trying to achieve ?

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <div id="app">
        <b-tbody v-for="(item, index) in list" :key="index">
            <b-tr>
                <b-td>{{ item }}</b-td>
            </b-tr>
            <b-tr v-for="(item2, index) in list2" :key="index">
                <b-td>{{ item2 }}</b-td>
            </b-tr>
        </b-tbody>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                list: ['a', 'b', 'c'],
                list2: ['d', 'e', 'f']
            }
            })
    </script>
</body>
</html>

Comments

0

Please share what you are trying to acheive so i could send a proper example

<b-tbody v-for="(item, index) in list" :key="index+'_table'">
 <b-tr v-for="(item2, rowIndex) in list2" :key="rowIndex+'_row'">
  <b-td></b-td>
 </b-tr>
</b-tbody>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.