【问题标题】:Vuetify <v-data-table> custom <th> headerVuetify <v-data-table> 自定义 <th> 标头
【发布时间】:2021-06-07 22:04:41
【问题描述】:

我正在使用 Vuetify &lt;v-data-table&gt;。 如何在表头&lt;th&gt;添加按钮?

这段代码是我迄今为止尝试过的。

<v-data-table v-model="selected" :headers="headers" :items="desserts">
  <template slot="items" slot-scope="row">
    <th><button>button</button></th>
  </template>
</v-data-table>  

<script>
export default {
    data:() =>({
    headers: [
          {
            text: 'Dessert (100g serving)',
            align: 'start',
            sortable: true,
            value: 'name',
          },
          { text: 'Calories', value: 'calories' },
          { text: 'Fat (g)', value: 'fat' },
          { text: 'Carbs (g)', value: 'carbs' },
          { text: 'Protein (g)', value: 'protein' },
          { text: 'Iron (%)', value: 'iron' },
        ],
});
</script>

请帮忙。

【问题讨论】:

    标签: html vue.js vuejs2 vuetify.js v-data-table


    【解决方案1】:

    您可以使用header.&lt;fieldname&gt; 插槽模板。

    例如,要定位第一列,name

    <v-data-table v-model="selected" :headers="headers" :items="desserts">
    
      <template v-slot:header.name="{ header }">
        {{ header.text }}
        <v-btn>Button</v-btn>
      </template>
    
    </v-data-table>
    

    【讨论】:

      猜你喜欢
      • 2021-04-17
      • 2020-02-26
      • 2019-11-10
      • 2020-12-13
      • 2019-11-19
      • 1970-01-01
      • 2020-06-27
      • 2021-02-11
      • 2021-05-17
      相关资源
      最近更新 更多