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

126
Visualizações
generate elements dynamically based on json file in bootstrap-vue

I'm working with BootstrapVue (Bootstrap 4.6 and VueJS 2) !

I want to create elements (input fields, dropdowns, checkboxes, etc.) dynamically based on a json file which is looking like that:

[
    {
        "unique_number": "1111",
        "key": "key1",
        "label": "Input 1",
        "input": "text",
        "value": ""
    },

    {
        "unique_number": "2222",
        "key": "key2",
        "label": "Input 2",
        "input": "text",
        "value": ""
    },

    {
        "unique_number": "3333",
        "key": "key3",
        "label": "Input 3",
        "input": "number",
        "value": ""
    }
]

So at the end there should be 3 input fields with 3 labels (Input 1, Input 2, Input 3)..

But I actually could not find something online to work with - so it would be very helpful if someone can help me out in this..

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to map through the data, and return a component that takes the data from .map

const array = [
    {
        "unique_number": "1111",
        "key": "key1",
        "label": "Input 1",
        "input": "text",
        "value": ""
    },

    {
        "unique_number": "2222",
        "key": "key2",
        "label": "Input 2",
        "input": "text",
        "value": ""
    },

    {
        "unique_number": "3333",
        "key": "key3",
        "label": "Input 3",
        "input": "number",
        "value": ""
    }
]

I don't use Vue, but I'm sure its similar to how its done in React:

array.map((element,key) => {
   return (
    <div key={key}>
      <SomeComponent prop={element.prop}/>
   </div>
   )
}
about 4 years ago · Juan Pablo Isaza 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