[英]How to add colors to vuetify table row
This is my vuetify table.这是我的 vuetify 表。
---------template----------- - - - - -模板 - - - - - -
<v-data-table
:headers="headers"
:items="desserts"
:items-per-page="5"
class="elevation-1"
>
</v-data-table>
------script------------- - - - 脚本 - - - - - - -
headers: [
{
text: 'Campaign Id',
align: 'start',
sortable: false,
value: 'id',
},
{ text: 'Created by', value: 'created' },
{ text: 'Controls', value: 'control' },
],
desserts: [
{
id: '1',
created:'ABBC',
control:''
},
{
id: '2',
created:'ABBC',
control: '',
},
]
I want to add colors to table row, as row after row.我想将 colors 添加到表行中,一行接一行。 how I do this?
我该怎么做?
I offer you this solution.我为您提供此解决方案。 https://codepen.io/lino96/pen/yLaRGmX?editors=101
https://codepen.io/lino96/pen/yLaRGmX?editors=101
Code HTML代码 HTML
<div id="app">
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
:items-per-page="5"
class="elevation-1"
:item-class="(item) => item.class">
</v-data-table>
</v-app>
</div>
Code JS代号JS
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
headers: [
{
text: 'Campaign Id',
align: 'start',
sortable: false,
value: 'id',
},
{ text: 'Created by', value: 'created' },
{ text: 'Controls', value: 'control' },
],
desserts: [
{
id: '1',
created:'ABBC',
control:'',
class: 'purple darken-1 white--text'
},
{
id: '2',
created:'ABBC',
control: '',
class: 'yellow darken-2'
},
],
}
},
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.