<template>
  <div>
    <input type="file" @change="onFileChange" />
    <button @click="uploadFile">Upload</button>
    <button @click="recognizeOcr">发票识别</button>
  </div>
</template>

<script>

import axios from 'axios';
export default {
  data() {
    return {
      selectedFile: null,
    };
  },
  methods: {
    onFileChange(e) {
      this.selectedFile = e.target.files[0];
    },
    uploadFile() {
      const formData = new FormData();
      formData.append('file', this.selectedFile, this.selectedFile.name);

      axios.post('http://127.0.0.1:8000/upload', formData, {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      })
          .then(response => {
            console.log(response);
          })
          .catch(error => {
            console.error(error);
          });
    },
    recognizeOcr() {

    }
  }
};
</script>