简体   繁体   English

如何在 QUASAR 中映射 Json 响应

[英]How to map Json response in QUASAR

I need to take all persons names, using quasar and vue3.我需要使用 quasar 和 vue3 获取所有人的姓名。

I need to take all persons data, but I only can take the first object fields like row.persons[0].name .我需要获取所有人的数据,但我只能获取第一个对象字段,例如row.persons[0].name

Quasar column data: Quasar 列数据:

  {
    name: "personName",
    label: "Name",
    field: rows => rows.persons.name, //here that I can't return both person content
    sortable: true,
    align: "center",
  },

Json response json响应

{
  "id": 4291,
  "persons": [
    {
      "id": 12485,
      "name": "",
      "email": "",
    },
    {
      "id": 21898,
      "name": "",
      "email": "",
      
    }
  ]
}

you could use map on rows.persons array你可以在 rows.persons 数组上使用map

for eg例如

rows.persons.map(person=>person.name)

will return array containing only the names将返回仅包含名称的数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM