How to display the index of an array using the vuetify data table?

前端 未结 4 814
清歌不尽
清歌不尽 2020-12-31 01:07

I have a response from server which has the array of data passing to my vue instance. I have completed the data table using that array.But all i need to know how can I displ

4条回答
  •  遥遥无期
    2020-12-31 01:48

    EDIT 7/30/19 As @titou10 mentioned, there is no index field within Vuetify 2.0.

    After looking around for a bit I was able to achieve this by utilizing the item. slot. This slot will return me an item. I created an array of IDs based on the object id and called indexOf(item.id) to get the index position.

    Code pen HERE.


    Vuetify 1.x

    Each one of your props object contains two keys: item and index. You can access the index for each item by doing props.index. Adding a new header is as easy as adding a new item to your headers array.

    Here is a codepen as an example. I am changing the first column of the data-table to the index position.

    https://codepen.io/potatogopher/pen/eGBpVp

提交回复
热议问题