Vuetify - How to highlight row on click in v-data-table

前端 未结 3 969
悲哀的现实
悲哀的现实 2020-12-16 23:04

How to highlight the selected row in v-data-table? i tried to modified the data by adding flag variable selected in the Example

In the above example cli

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 23:47

    How to make the row clickable is allready explained by others but not how to toggle the row selection. The selection state can be checked through isSelected and then set accordingly.

    To style the selected row properly you need something more to take into account: the dark and light theme and the hover css pseudo class - which is overridden through the important tag so we need to restyle it.

    Check out the Codepen Example

    methods: {
        rowClick: function (item, row) {      
          let selectState = (row.isSelected) ? false : true;
          row.select(selectState);
        }
    }
    
    
    
    

提交回复
热议问题