我想要做的就是对于包含等于 lowestEntry
的条目的给定行,更改背景颜色。
<v-col cols="8">
<v-data-table
:loading="loadEntryTable"
loading-text="A procurar dados..."
:headers="this.entryheaders"
:items="this.stockentries"
:items-per-page="10"
>
//Have tried using the v-slot.item to achieve it but no success
</v-data-table>
</v-col>
我想将 tr
背景颜色改为绿色。在 ìtem.id_entry == lowestEntry["id_entry"]
时突出显示它。
原文由 Ricardo F. 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您使用的是较新版本的 vuetify,则可以访问
item-class
作为 ---v-data-table
--- 的属性。这将提供item
作为回调函数的第一个参数。然后定义将返回类名的函数:
然后只需为
style-1
和style-2
定义类:这是此示例的代码笔,适用于您 codepen example
编辑 如果
:item-class
不适用于您当前版本的 Vuetify,或者您需要对行进行更多控制而不只是绑定一个类,您将必须使用item
插槽和手动绑定类/样式/等。定位
item
插槽并手动将类绑定到行:或者,您可以传递
:class="customRowClass(item, lowestEntry)"
并定义customRowClass
方法: