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

278
Visualizações
How to create a dynamic URL in Vue 3?

I'm using Vue 3.2.13 version. I am using Avatars by DiceBear for my application for users' profile pictures.
The URL for the GET endpoint is:
https://avatars.dicebear.com/v2/avataaars/{{username}}.svg?options[mood][]=happy

Here each string generates a unique image and I use the username to generate a unique avatar for each user. The {username} in the URL is the placeholder for the user's username. It should be dynamically replaced by the username received from the user's API endpoint.
So the sample UI should be like the following;
sample UI
But I get the same image for different usernames. But other fetched data properly placed. Here is the UI I got.
my UI
Here is my code;

<div class="card" style="width: 18rem" v-for="(person, key) in people" :key="key">
          <img class="card-img-top" src="https://avatars.dicebear.com/v2/avataaars/{{person.username}}.svg?options[mood][]=happy" alt="Card image cap" />
          <h5 class="card-title">
            {{ person.name }}
          </h5>
          <div class="card-text">
            <i class="fa-solid fa-envelope"> </i>
            <p class="icon">
              {{ person.email }}
            </p>
            <br />

            <i class="fa-solid fa-phone"></i>
            <p class="icon">
              {{ person.phone }}
            </p>
            <br />
created: async function () {
    try {
      this.loading = true;
      let response = await UserService.getAllUsers();
      this.people = response.data;
      this.loading = false;
    } catch (error) {
      this.errorMessage = error;
      this.loading = false;
    }
  },

Thank you.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Bind it using string template `` :

:src="`https://avatars.dicebear.com/v2/avataaars/${person.username}.svg?options[mood][]=happy`"
about 4 years ago · Santiago Trujillo Relatório
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