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

260
Visualizações
create an array of objects in the computed method vuejs?

I already appreciate your advice and answers, this time I go to you for the next problem I pass context, I want to create a dynamic table with quasar and vueJS this table will change according to a select field I have managed to bring the columns of the Selected tables, what I can't do is paint them in the view, since for this I must generate the following structure to be able to paint the table:

 columns: [
         {
           name: 'id', align: 'center', label: 'id', field: 'id'
         },
         {
           name: 'name', align: 'center', label: 'name', field: 'name'
         },
         {
           name: 'age', align: 'center', label: 'age', field: 'age'
         }
       ]
     }

I want to form the structure above from an array that comes to me from the database (the columns of the table), what I receive is the following:

const columnsTable = [
   "id",
   "name",
   "age"
];

I am trying as follows in my computed method: My computed method to generate the array of objects The result of this is not what was expected since in each key of my object the entire array is entered in this way. colums in the image The variable colums is where I want to generate the array of objects described at the beginning of the question. I appreciate your answers and opinions, anything would help me a lot, thank you very much.

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

0

Maybe something like following snippet:

const columnsTable = [
   "id",
   "name",
   "age"
];
const res = []
columnsTable.forEach(c => {
  res.push({name: c, align: 'center', label: c, field: c})
})
console.log(res)

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