B
B
BonBon Slick2020-08-10 10:46:50
Vue.js
BonBon Slick, 2020-08-10 10:46:50

How to skip or start from another index in v-for?

<tr v-for="(value, index) in this.pedometer.gps.points"
                        :key="index"
                    >
                        <td v-text="`${value.latitude} ${value.longitude}`" />
                        <td v-text="`${pedometer.gps.points[index + 1].latitude} ${pedometer.gps.points[index + 1].longitude}`" />
                        <td v-text="distanceBetweenCoords(
                            value.latitude,
                            value.longitude,
                        pedometer.gps.points[index + 1].latitude,
                        pedometer.gps.points[index + 1].longitude)"
                        />
                    </tr>

client.js?06a0:77 TypeError: Cannot read property 'latitude' of undefined
    at eval (index.vue?9726:269)


Naturally, the arr.length + 1 index is not in the array.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Vasilev, 2020-08-10
@BonBonSlick

v-if="(index === value)"
v-if="(index > value)"
v-if="(index < value)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question