How can I filter data when button pressed using json files on Vue js. I want to filter by category which is inside each object on data.
portfolio-v1.json
{
"data":[
{
"image_path":"static/products/DELUXE-BATHROBE.jpg",
"title":"Beautiful Designs",
"heading":"Lorem Ipsum is simply dummy.",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"vendor":"George Courey",
"category":"Blanket"
},
{
"image_path":"static/products/HOME-CARE-SLIP-PAD.png",
"title":"Mutifunctionals Blocks",
"heading":"Lorem Ipsum is simply dummy.",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"vendor": "George Courey",
"category": "Blanket"
},
{
"image_path":"static/products/HERRINGBONE-THERMAL-BLANKET.jpg",
"title":"Vuejs App For Game",
"heading":"Lorem Ipsum is simply dummy.",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"vendor": "George Courey",
"category": "Blanket"
}
]
}
portfolioGrid.vue
<template>
<div class="row col-space">
<!-- START PORTFOLIO FILTER AREA -->
<div class="col-12">
<div class="text-center">
<div class="portfolio-filter mb-40">
<button class="active" data-filter="*">Show all</button>
<button data-filter=".cat1">Linens</button>
<button data-filter=".cat2">Blankets</button>
<button data-filter=".cat3">Protective Products</button>
<button data-filter=".cat4">Top Sheets</button>
<button data-filter=".cat5">Staff Apparel</button>
<button data-filter=".cat6">Towels</button>
<button data-filter=".cat7">Bathrobes & Slippers</button>
</div>
</div>
</div>
<!-- END PORTFOLIO FILTER AREA -->
<div v-for="(portfolio,index) of portfoliov1.data.slice(0,showNoOfPosts)" :key="index"
class="col-sm-12 col-md-6 col-lg-4 ">
<div class="overlay-wrap">
<img :src="portfolio.image_path" alt="gallery images" class="img-fluid border-rad w-100" height="500"
width="500"/>
<a :href="portfolio.image_path" class="card-img-overlay primary-tp-layer pos-center text-center"
data-fancybox="images">
<span class="center-holder">
<a class="ih-fade-down square-40 rounded-circle bg-white shadow-md">
<i class="fa fa-plus align-middle"></i>
</a>
</span>
</a>
</div>
</div>
</div>
</template>
<script>
import portfoliov1 from 'Components/data/portfolio-v1.json'
export default {
props: ['showNoOfPosts'],
data() {
return {
portfoliov1
}
}
}
</script>
I want to just display the items from the category selected on buttons. It should grab the category and check if it was the one selected by user then display only the items that contain that category. How can this be done.