Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
How can I get the next 6 days in a v-for loop in Vue3?

I have a specific date that I am wanting to then get the next 6 days (to have a week ahead type of component) for. I am thinking I can just have my initial date and then do a v-for range loop like:

<span v-for="n in 7">{{ n }}</span>

where the first element would be the passed-in date. But I am not exactly sure what the best way to achieve this would be?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's possible to calculate the next 7 dates directly within the <template>:

<span v-for="n in 7">{{ new Date().setDate(new Date().getDate() + n) }}</span>

demo 1

Alternatively, you could move that into <script> to declutter the <template>:

<script setup>
const today = new Date()
const nextSevenDays = Array(7).fill().map((_, i) => new Date(today).setDate(today.getDate() + i))
</script>

Then update the v-for to render it:

<template>
  <span v-for="date in nextSevenDays">{{ date }}</span>
</template>

demo 2

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda