如何禁用Vuetify数据表的悬停效果?

Bas*_*spa 9 css vuetify.js

Vuetify 中的数据表默认具有悬停效果。当我检查表格行时,我发现应用了这个 CSS 类,

.theme--light.v-data-table tbody tr:hover:not(.v-data-table__expanded__content) {
    background: #eee;
}
Run Code Online (Sandbox Code Playgroud)

因此,这似乎为表格行添加了背景颜色。但是当我将这个作用域 CSS 添加到 Vuetify 组件时,

<template>
  <v-data-table
    :headers="headers"
    :items="items"
    :disable-sort="true"
    hide-default-footer
    :item-key="itemKey"
  >
    <template v-for="slot in Object.keys($scopedSlots)" :slot="slot" slot-scope="scope">
      <slot :name="slot" v-bind="scope" />
    </template>
  </v-data-table>
</template>

<script>
export default {
  name: "BaseDataTable",
  props: {
    headers: Array,
    items: Array,
    itemKey: {
      type: String,
      default: "id"
    }
  }
};
</script>

<style scoped>
.theme--light.v-data-table
  tbody
  tr:hover:not(.v-data-table__expanded__content) {
  background: #fff;
}
</style>
Run Code Online (Sandbox Code Playgroud)

它对我添加的新 CSS 没有任何作用。即使我!important在背景之后添加。有人能告诉我为什么新的 CSS 规则不起作用甚至没有应用吗?因为我什至无法在控制台中看到它们。

JPi*_*son 16

这是我的解决方案

<style lang="scss">  
  tbody {
     tr:hover {
        background-color: transparent !important;
     }
  }
</style>
Run Code Online (Sandbox Code Playgroud)

  • 在最新的 vuetify 上完美运行 - 干杯 (2认同)