styling individual rows in a Vuetify data table

后端 未结 4 2288
没有蜡笔的小新
没有蜡笔的小新 2021-02-14 04:36

Can I apply different styling for a specific row in a data table?

This is my code:



        
4条回答
  •  無奈伤痛
    2021-02-14 05:20

    You can now use vuetifys data table item-class property:

    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
      methods: {
        row_classes(item) {
            if (item.calories < 200) {
              return "orange"; //can also return multiple classes e.g ["orange","disabled"]
            } 
        }
      },
      data () {
        return {
          singleSelect: false,
          selected: [],
          headers: [{text: 'Dessert (100g serving)', value: 'name'},
                    { text: 'Calories', value: 'calories' },
          ],
          desserts: [{name: 'Frozen Yogurt',calories: 159,},
                     {name: 'Ice cream sandwich',calories: 237,},
                     {name: 'Eclair',calories: 262,},
                     {name: 'Cupcake',calories: 305,},
          ],
        }
      },
    })
    .orange {
      background-color: orange;
    }
    
    
    

提交回复
热议问题