Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify data table is not showing data

Vuetify data table is not showing data, it shows that there are 1 row out of 1 displayed, but the table body is empty. My component code:

<template>
  <v-data-table
    :headers="headers"
    :items="desserts"
  >
  </v-data-table>
</template>

<script>
export default {
  name: 'Users',
  data () {
    return {
      headers: [
        {
          text: 'Dessert (100g serving)',
          align: 'left',
          sortable: false,
          value: 'name'
        },
        { text: 'Fat (g)', value: 'fat' },
      ],
      desserts: [
        {
          name: 'Frozen Yogurt',
          fat: 6.0,
        },
      ]
    }
  }
}
</script>

<style scoped  lang="stylus">
</style>

Result:

enter image description here

Any idea how to fix this?

like image 310
user2626972 Avatar asked Jul 24 '19 10:07

user2626972


People also ask

What is V data table?

# Data tables The v-data-table component is used for displaying tabular data. Features include sorting, searching, pagination, content-editing, and row selection.

Is Vuetify easy to learn?

Unlike other frameworks, Vuetify is designed from the ground up to be easy to learn and rewarding to master with hundreds of carefully crafted components from the Material Design specification .


1 Answers

Since you're using Vuetify 1.x You should add a template with scoped slot :

  <v-data-table
    :headers="headers"
    :items="desserts"
  >
  <template v-slot:items="props">

      <td class="text-xs-right">{{ props.item.name }}</td>
      <td class="text-xs-right">{{ props.item.fat }}</td>

    </template>
</v-data-table>

or you should upgrade to the version 2.0 which does simply :

<template>
  <v-data-table
    :headers="headers"
    :items="desserts"
    :items-per-page="5"
    class="elevation-1"
  ></v-data-table>
</template>

if you want to customize your data cells check this answer

like image 174
Boussadjra Brahim Avatar answered Oct 11 '22 02:10

Boussadjra Brahim