Vuetify table - 页面重新加载后自定义 css 未应用于第一行

Vuetify table - custom css isn't applied to first row after page reload

Table:

<v-card :dark="true">
      <v-card-title>
        <v-btn color="indigo" dark @click="initialize"><v-icon dark>refresh</v-icon></v-btn>
        <v-spacer></v-spacer>
        <v-text-field append-icon="search" label="Search" single-line hide-details></v-text-field>
      </v-card-title>
      <v-data-table :dark="true" :headers="headers" :items="expenses" hide-actions class="elevation-1">
        <template slot="headers" slot-scope="props">
          <tr>
            <th v-for="header in props.headers">{{header.text}}</th>
          </tr>
        </template>
        <template slot="items" slot-scope="props">
          <tr v-bind:class="getClass(props.item)">
            <td class="text-xs-center">{{ props.item.year }}</td>
            <td class="text-xs-center">{{ props.item.month }}</td>
            <td class="text-xs-center">{{ props.item.day }}</td>
            <td class="text-xs-center">{{ props.item.description }}</td>
            <td class="text-xs-center">{{ props.item.value }}</td>
            <td class="text-xs-center">{{ props.item.category }}</td>
            <td class="text-xs-center">{{ props.item.details }}</td>
            <td class="justify-center layout px-0">
              <v-btn icon class="mx-0" @click="deleteItem(props.item)">
                <v-icon color="pink">delete</v-icon>
              </v-btn>
            </td>
          </tr>
        </template>
        <template slot="no-data">
          <v-btn color="primary" @click="initialize">Reset</v-btn>
        </template>
      </v-data-table>
    </v-card>

Css 页面重新加载前,代码在Webstorm中编辑并自动编译后:

重新加载后:

如果我只删除第一行,无论第一行是什么,都会发生同样的情况。

我遇到了同样的问题。

这里的问题是您覆盖了包含 <tr> 标签的项目插槽。没有它一切都会正常工作。但对我来说,这不是解决方案,所以如果您还想覆盖 <tr> 标记,请向其添加 :key,如下所示:<tr :key="props.index">。 查看 v-data-table here 的来源。 老实说,我不知道为什么它会产生如此大的不同,但在我的情况下解决了问题(我怀疑它与 vue 列表渲染有关)。

希望对您有所帮助!