[Vuejs]-My Laravel Vue App Does Not Delete a Record. Do I need to Bind my Button so that it will redirect to the controller?

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.

Leave a comment