首页 > 解决方案 > vuetify v-data-table 不显示嵌套对象数据

问题描述

我有使用 vuetify 的 v-datatable 我想显示嵌套数据不幸的是我无法获得嵌套对象值这是我的代码

<template slot="items" slot-scope="props">
          <tr @click="rowClick(props.item.name)">
            <td
              class="text-xs-right"
            >{{ props.item.firstName + props.item.middleName + props.item.lastName}}</td>
            <td class="text-xs-right">{{ props.item.gender }}</td>
            <td class="text-xs-right">{{ props.item.dateOfBirth }}</td>
            <td class="text-xs-right">{{ props.item }}</td>
          </tr>
        </template>

这是标题

  headers: [
    {
      text: "MCN",
      align: "left",
      sortable: false,
      value: "medicalRecordNumber",
      width: "16%"
    },
    { text: "Full Name", value: "fullName", width: "16%" },
    { text: "Gender", value: "gender", width: "16%" },
    { text: "Date Of Birth", value: "dateOfBirth", width: "16%" },
    { text: "Phone Number", value: "address", width: "16%" },
    { text: "Actions", value: "action", sortable: false }
  ],

和我的数据

{
            "medicalRecordNumber": "dsUlBnusoH",
            "fullName": "Rozella SchusterProf. Chloe Hauck DDSAthena Hill III",
            "firstName": "Rozella Schuster",
            "middleName": "Prof. Chloe Hauck DDS",
            "lastName": "Athena Hill III",
            "gender": "Female",
            "dateOfBirth": "2018-04-18",
            "language": "Tigregna",
            "religion": "Catholic",
            "address": {
                "region": "Addis Ababa",
                "woreda": "bole",
                "kebele": "10",
                "houseNumber": "35698",
                "telPhoneNumber": null,
                "mobilePhoneNumber": null
            },
            "emergencyContact": {
                "firstName": "Krista Collins III",
                "middleName": "Onie Roob",
                "lastName": "Dr. Vivien Miller PhD",
                "emergencyContactAddress": null
            }
        }

我得到了值,但没有得到它显示的嵌套值 [object Object]

标签: javascriptlaravelvue.jsvuetify.js

解决方案


代替

{ text: "Phone Number", value: "address", width: "16%" },

{ text: "Phone Number", value: "address.telPhoneNumber", width: "16%" },

推荐阅读