【发布时间】:2021-08-30 03:17:21
【问题描述】:
嘿,我是 vue js 和 vuetify 的新手。在我的 editProductSave 中,我想传递另一个变量,它是表中行的索引。这是我当前的代码,我将如何实现?该表是使用 vuetify v-data-table 绘制的
完整代码
<template>
<v-card>
<v-data-table
:headers="tableFields"
:items="programs"
:items-per-page="5">
<template v-slot:[`item._id.$oid`]="{ item }">
{{item._id.$oid}}
</template>
<template v-slot:[`item.tags`]="props">
<v-edit-dialog
:return-value.sync="props.item.tags"
large
persistent
@save="editProductSave(props.item)">
<div>{{props.item.tags.length === 0 ? '' : props.item.tags}}</div>
<template v-slot:input>
<div class="mt-1 text-h2">
Update Tag
</div>
<v-text-field
v-model="props.item.tags"
label="Edit"
single-line
counter
autofocus
></v-text-field>
</template>
</v-edit-dialog>
</template>
<script>
import tdmApi from "../services/api/Database";
export default {
props: ["DatabaseList"],
computed: {
totalRows() {
return this.programs.length;
},
},
created () {
this.viewTdmDatabase();
},
data () {
return {
tableFields: [
{text:'ID',value:'_id.$oid'},
{text:'Tag',value:'tags'},
],
programs: [],
}
},
</script>
【问题讨论】:
-
行索引在哪里?
-
您使用的是哪个插槽?请分享整个代码
-
@BeshambherChaukhwan 我是 vue js 的新手,我正在使用 v-data-table 绘制表格
-
@BoussadjraBrahim 添加了整个代码
标签: vue.js vuetify.js v-data-table