This question has already been answered:
- Hiding list items 2 answers
How can I hide an item from the list by clicking on the hide button?
<template> <div> <div class="cards__list" v-if="items.length > 0"> <div class="row"> <div class="col-md-3 mb-3" v-for="item in items" :key="item.id"> <div class="card"> <div class="card-body"> <h5 class="card-title">{{item.title}}</h5> <button type="button" class="btn btn-secondary" @click="hideItem(item.id)">hide</button> </div> </div> </div> </div> </div> </div> </template> <script> export default { data() { return { items: [] } }, created() { this.fetchItems(); }, methods: { fetchItems() { this.loading = true; fetch("/api/articles") .then(res => res.json()) .then(res => { this.loading = false; this.items = res.data; }) .catch(err => console.log(err)); }, hideItem(id) { } } } </script>
style display, to whomslice array))) - Rustam Gimranov