0π
β
<tr v-for="post in posts" :key="post.id">
<td>{{ post.id }}</td>
<td>{{ post.title }}</td>
<td>{{ post.body }}</td>
<td><router-link :to="{name: 'edit', params: { id: post.id }}" class="btn btn-primary">Edit</router-link></td>
<td><button @click="deletePost(post.id)" class="btn btn-danger">Delete</button></td>
</tr>
The reason why it is not deleting because youβre not trigging the deletePost function. You should call it on the click event like the code above.
Source:stackexchange.com