Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
how to split files from multiple v-file-input

I'm trying to upload several files in one v-file input, but then have them stored each in v-file-input. But they stay as uploaded - in one v-file-input all.

part of my component-

<v-file-input
    dense
    single-line
    multiple
    :value="file"
    @change="$emit('changeFile', $event)"
/>

changeFile handler

changeFile(obj, index, value) {
      if (!Array.isArray(value)) {
        obj[index].file = value;
      } else {
        let i = index,
          newArr = [];
        if (index < obj.length && obj.length != 1) {
          newArr = obj.slice(index + 1, obj.length + 1);
          obj.splice(index + 1);
        }
        value.forEach((it) => {
          if (i + 1 == obj.length) {
            obj[i].file = it;
          } else {
            obj.push({
              file: it,
              selectedItem: "install-workflow",
              Hash: new Date().getTime(),
            });
          }
          i++;
        });
        if (newArr.length > 0) {
          obj = [...newArr];
        }
      }
      this.WMSdef = obj;
    },

the idea of file handling is that user can add several files to any place in the array and we must shift elements in it not to lose them.

component is used like this

    <vue-file-and-box
      v-for="(item, index) in WMSdef"
      :key="item.Hash"
      :items="Phases"
      :text="item.file"
      :value="item.selectedItem"
      @change="changePhase(WMSdef, index, ...arguments)"
      @changeFile="changeFile(WMSdef, index, ...arguments)"
      @clickAdd="addFile(WMSdef)"
      @clickDelete="deleteFile(WMSdef, 'WMS', item)"
    />

and in vue dev tools I see that WMSdef as an array is stored correct - it's an array of n files and so it should be shown with v-for as an array of my components. but I get one vue-file-and-box with n files and n-1 empty vue-file-and-box components this is how it looks

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda