简体   繁体   English

在 Vuetify 中,如何在每一行中添加一个按钮<v-data-table> ?</v-data-table>

[英]In Vuetify, how to add a button into each row in <v-data-table>?

The screenshot belwo is an example in https://vuetifyjs.com/en/components/data-tables/下面的屏幕截图是https://vuetifyjs.com/en/components/data-tables/中的一个示例在此处输入图像描述 And its code is:它的代码是:

<template>
  <v-data-table
    :headers="headers"
    :items="desserts"
    :items-per-page="5"
    class="elevation-1"
  ></v-data-table>
</template>

I am wondering how to add a <v-btn> into each row to navigate to another component?我想知道如何在每一行中添加一个<v-btn> 以导航到另一个组件?
Like, adding a column which contains buttons called "view" in each row, and clicking on them will navigate to the page containing the details of the corresponding dessert.就像,在每一行中添加一个包含称为“查看”按钮的列,然后单击它们将导航到包含相应甜点详细信息的页面。

Thanks!谢谢!

You can add a header called action .您可以添加一个名为action的 header 。

  { text: "", value: "action" }

And then specify the rendering of this header with a slot .然后用slot指定这个 header 的渲染。

<v-data-table :headers="headers" :items="desserts">
  <template v-slot:item.action="{ item }">
    <v-btn>OPEN</v-btn>
  </template>
</v-data-table>

https://vuetifyjs.com/en/components/data-tables/#simple-checkbox https://vuetifyjs.com/en/components/data-tables/#simple-checkbox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM