G
G
Grouver2021-06-25 08:22:30
Vue.js
Grouver, 2021-06-25 08:22:30

Why is the click not working?

<div class="container__wrap" id="app">
    <div class="header">
        <input type="file" v-model="file" class="" id="file" ref="file">     
        <a class="button"   v-on:click="submitFile">Отправить </a>
    </div>

    <div class="container">

        <div class="slider" id="s-1"></div>
        <div class="slider" id="s-2"></div>
        <div class="slider" id="s-3"></div>
        <div class="slider" id="s-4"></div>
        <div class="slider" id="s-5"></div>

    </div>
</div>

var app = new Vue({
        el: '#app',
        data() {
            return {
                file: '',
                text: 'ww',
                seen: true,
            }
        },
        methods: {
            submitFile() {
                console.log('Отправляем');
                let formData = new FormData();
                formData.append('file', this.file);
                axios.post('/vendor/FileController',
                    formData,
                    {
                        headers: {
                            'Content-Type': 'multipart/form-data'
                        }
                    }
                ).then(function () {
                    console.log('SUCCESS!!');
                })
                    .catch(function () {
                        console.log('FAILURE!!');
                    });
            },
            handleFileUpload() {
                this.file = this.$refs.file.files[0];
            }
        }
    });


click on submit button not working

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-06-25
@Aetae

Everything works, albeit with warnings:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question