簡體   English   中英

如何在 QUASAR 中映射 Json 響應

[英]How to map Json response in QUASAR

我需要使用 quasar 和 vue3 獲取所有人的姓名。

我需要獲取所有人的數據,但我只能獲取第一個對象字段,例如row.persons[0].name

Quasar 列數據:

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

json響應

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

你可以在 rows.persons 數組上使用map

例如

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

將返回僅包含名稱的數組

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM