Mathias Hillmann
Mathias Hillmann

Reputation: 1837

Make rowspan be 2 if index of v-for is different than 2 values

I have the following table:

<table class="table table-condensed table-sm table-striped table-bordered" id="list">
    <thead>
        <tr>
            <th v-for="(column, index) in columns" :key="index" :rowspan="{ '2': index != 'new_value' || 'old_value' }">
                {{ column }}
            </th>
        </tr>
    </thead>
    <tbody>
        <tr v-for="(entry, index) in results" :key="index">
            <td v-for="(key, index) in columns" :key="index">
                {{ entry._source[index] }}
            </td>
        </tr>
    </tbody>
</table>

In which I want the rowspan for the table head that isn't new_value or old_value to be 2, however in the current code the table head has a [object Object] instead of a number:

<th rowspan="[object Object]">User</th>

What should I do?

Upvotes: 0

Views: 50

Answers (1)

akuiper
akuiper

Reputation: 215117

rowspan attribute expects a number not an object. Try:

:rowspan="index !== 'new_value' && index !== 'old_value' ? 2 : 1"

Upvotes: 1

Related Questions