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

165
Visualizações
How to create an image programmatically and display it in VueJS?

I want to create an image in VueJS with data which I receive from the server. This data includes the title of the image, the type of the image (e.g. image/png) and the content of an image (which is a gibberish string).

I tried to create a method which returns a new File like so:

methods: {
    getFile(img: { content: any; title: string; type: any }): File {
      return new File([img.content], img.title, {
        type: img.type,
      });
    },
  },

And then I tried to bind the created method to the img tag like so:

<template>
  <div>
    <img :src="getFile(image)" />
  </div>
</template>

Where image is an object of type {title: string; type: string; content: string;}.

Unfortunately I receive the following error:

Invalid prop: type check failed for prop "src". Expected String, Object, got File

How can I create an image file and bind it to the View to display it?

Thanks for any help!

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