在计算方法vuejs中创建一个对象数组?

create an array of objects in the computed method vuejs?

我已经很感谢你的建议和回答,这次我去找你解决下一个问题我传递上下文,我想用类星体和 vueJS 创建一个动态的 table 这个 table 会改变根据 select 字段,我设法将 Selected table 的列带入,我不能做的是在视图中绘制它们,因为为此我必须生成以下结构能够绘制 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'
         }
       ]
     }

我想从数据库(table 的列)传来的数组中形成上面的结构,我收到的是以下内容:

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

我在我的计算方法中尝试如下: My computed method to generate the array of objects 这不是预期的结果,因为在我的对象的每个键中,整个数组都是以这种方式输入的。 colums in the image 变量 colums 是我要生成问题开头描述的对象数组的地方。 感谢您的回答和意见,任何事情都会对我有很大帮助,非常感谢。

可能类似于以下代码段:

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