Reputation: 139
I want to display the values in the day object such as: Sunday, Monday, etc.
For now, here my code:
<div class="col-md-3 col-sm-6" v-for="item in result" v-bind:key="item.schedule_id">
{{ item.day }}
</div>
My result:
[ "Monday", "Wednesday" ]
Upvotes: 1
Views: 891
Reputation: 206
I think it's a better and easy solution
<div class="col-md-3 col-sm-6" v-for="item in result" :key="item.schedule_id"> {{ item.day.join(',') }} </div>
Upvotes: 2
Reputation: 1
If you want just return the days use the flatMap
function :
<div class="col-md-3 col-sm-6" v-for="day in result.flatMap(item=>item.day)" v-bind:key="day">
{{ day }}
</div>
if you want to separate them by comma use this :
<div class="col-md-3 col-sm-6" >
{{ result.flatMap(item=>item.day).join(',') }}
</div>
or between arrays:
<div class="col-md-3 col-sm-6" >
{{ result.map(item=>item.day).join(',') }}
</div>
Upvotes: 2
Reputation: 1220
You can do another loop as
<div class="col-md-3 col-sm-6" v-for="item in result" v-bind:key="item.schedule_id">
<div v-for="(day , index) in item.day" :key="index">
{{day}}
</div>
</div>
Upvotes: 2