[Vuejs]-Vue.js basic function not working as wanted

0👍

data() {
    return {
       sessions:[
                 { name:'test',
                   value:false,
                   id:1
                 },
                 { name:'test1',
                   value:false,
                   id:2
                 },
                 { name:'test2',
                   value:false,
                   id:3
                 }
                ]
  
           }
     }


methods:{
 logToggler(_index) {
   for(let index=0;index<sessions.length;index++) {
     if(index == _index)
      sessions[index].value = true
     else
      sessions[index].value = false
   }
 }
}

Template

 <div class = "rowuserlog" id="log-container" v-for="(session,index) in sessions" :key="session.id" 
>
<div id="profile-log-title" @click="logToggler(index)" v-if="session.value"> {{session.name}} </div>

Leave a comment