ok so this isn't really some clean code i know. What i am trying to do here is that whenever the index in my v-for reach 3, i wanna print out a day in my weekday array.
Right now in my methods the afficherJour(index) function the i doesn't seem to increment ( it always stay at 0 ) so everytime my index reach 3%3 = 0 it only prints out Monday, but i want Monday, Tuesday, etc..
Any idea to fix this ? thank you !
<template>
<div id="app">
<div>
<h1>
<span>Weather</span>
</h1>
</div>
<div>
<span>Votre location actuelle est: {{this.city}}</span>
</div>
<span>il fait: {{this.forecast[0]}}</span>
<div>
<ul v-for="(user, index) in forecast" :key="user.main">
<li>{{afficherJour(index+1)}}Temperature min: {{user.main.temp_min}}, Temperature max: {{user.main.temp_max}}</li>
</ul>
</div>
</div>
</template>
<script>
//import {getCity, getForecast} from '@/api/api.js'
import * as api from "@/api/api";
//import Forecast from '@/components/Forecast';
//import HeaderWeather from '@/components/HeaderWeather';
//<span>il fait: {{this.forecast}}</span>
export default {
name: 'App',
components: {
//HeaderWeather
},
data(){
return {
city: undefined,
forecast: [],
weekday: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
lat: undefined,
temp_max: [],
list: undefined
}
},
methods: {
afficherJour(index){
for (let i = 0; i < this.weekday.length; i++){
if(index %8 == 0){
return this.weekday[i];
}
}