hi, i have a list of shipment-with-zones collection passed into vue component, the collection has long list of zones sorted by countries so i need to implement show more / show less functionality for multiple collections on shipping zones.
this is what i have currently,
// this is the shipping zone list, i'm using slice to show only 5 zones as soon as the component renders on the page
<p v-for="(zone, index) in shipment.zone.slice(0, limitResults)" :key="index" v-text="zone.state_name"></p>
// this is the show less/more button
<a @click="showAllRegions(shipment.zone.length)" v-text="expandName"></a>
<script>
export default {
props: ['shipment'],
data() {
return {
limitResults : 5,
expandName : '... Show regions'
};
},
methods: {
showAllRegions (count){
if (this.limitResults == count) {
this.limitResults = 5;
this.expandName = '... Show Regions';
}else{
this.limitResults = count;
this.expandName = '... Hide Regions';
}
}
}
};
</script>
the code is working only if i have 1 zone in the shipping collection and it wont work for multiple zones.
Is there is a way on how to make it work on, Any ideas ???