1

подскажите, как передать параметр при удалении?

<template>
    <div class="blacklist">
        <form action="" class="search">
            <input type="text"  v-model="url"  name="url" placeholder="Что ищем?" value="" >
        </form>
        <div class="preloader" v-if="loading"><div class="ball"></div><div class="ball1"></div></div>
        <table>
            <thead>
            <tr>
                <th></th>
                <th>Запрещенный URL-адрес</th>
                <th>Причина запрета</th>
                <th>Действия</th>
            </tr>
            </thead>
            <tbody v-for="blackl in blacklist">
            <tr>
                <td>{{ blackl.id}}</td>
                <td>{{ blackl.url}}</td>
                <td>{{ blackl.content}}</td>
                <td>
                    <div class="data-action">
                        <a href="" class="btn-edit"><svg class="editp"><use xlink:href="#editp"></use></svg></a>
                        <button type="button" @click="deleteb(blackl.id)"  class="btn-delete"><svg class="deletep"><use xlink:href="#deletep"></use></svg></button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</template>

<script>
    import axios from 'axios'

    export default {
        el: '#admin-blacklist',
        data: function(){
            return {
                loading: false,
                url: null,
                blacklist: []
            }
        },
        watch: {
            url(after, before) {
                this.fetch();
            }
        },
        mounted() {
            this.update()
        },
        methods: {
            fetch: function (){
                this.loading = true;
                axios.post('/admin/blacklist/search', {  url: this.url } )
                    .then((response) => {
                        this.blacklist = response.data
                        this.loading = false;
                    })
                    .catch(error => {});
            },
            update: function () {
                this.loading = true;
                axios.get('/admin/blacklist/list').then((response) => {
                    this.blacklist = response.data
                    this.loading = false;
                });
            },
            deleteb: function () {
                axios.post('/admin/blacklist/delete', {  id: blackl.id } )
                    .then((response) => {
                        response.data
                        toast.fire({
                            type: 'success',
                            title: 'Удалено!'.response.data.id
                        })
                    })
                    .catch(error => {});
            }
        }
    }
</script>

1 ответ 1

1

Вы передали пераметр, но не прийняли его у своём методе.

deleteb(id) {
            axios.post('/admin/blacklist/delete', { id } )
                .then((response) => {
                    response.data
                    toast.fire({
                        type: 'success',
                        title: 'Удалено!'.response.data.id
                    })
                })
                .catch(error => {});
        }

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.