javascript - 如何通过 Accordion 显示数据表

标签 javascript vue.js datatable accordion vuetify.js

我在创建 Accordion 表时遇到了一些麻烦。我创建了一个 Accordion 组件和一个 Table 组件。虽然彼此独立,但它工作得很好,但我无法让任何 table 出现在 Accordion 中。

//js part of accordion component

import Table from "../Table/index.vue"
export default {
name: 'accordion',
components: { Table },
mounted () {
},
data(){
return {
  items: [
  { id: "mc", title: "Medical Checkup", text: this.components.Table },
  { id: "ac", title: "Application connected", text: 
this.components.Table },
  { id: "p", title: "Programs", text: this.components.Table },
  { id: "pl", title: "Pain list", text: this.components.Table }
]
}
}
}

//html part of accordion component 

<div>
<div ref="list" class="list">
<transition-group class="flip-list" name="flip-list" ref="tg1" 
tag="div">
<div v-for="(item,index) in items" :key="item.id" class="item">
<slot name="item" :class="{active:item.isOpen}" :item="item" 
:index="index">
<v-expansion-panel id="exp1">
<v-expansion-panel-content>  
<div slot="header" class="drop-target handle2">
<span>{{item.title}}</span> 
</div>
<v-card>
<v-card-text>
<div slot="item">{{Table}}</div>
</v-card-text>
</v-card>
</v-expansion-panel-content>
</v-expansion-panel>
</slot>
</div>
</transition-group>
</div>
</div>

所以,关键是:我怎样才能使数据表出现在 Accordion 中?就像当您单击其中一个标题时它会出现而不是某些文本?

非常感谢

最佳答案

已解决! 万一(如果人们遇到和我一样的问题),这里是代码(html/js)。

//html goes here

<div id="app">
<v-app id="inspire">
<v-data-table :headers="mainHeaders"
:items="mainItems"
item-key="title"
hide-actions
expand
class="elevation-1">
<template slot="items" scope="props">
<tr @click="props.expanded = !props.expanded">
<td class="text-xs">{{ props.item.title }}</td>
</tr>
</template>
<template slot="expand" scope="props">
<v-data-table :headers="subHeaders"
:items="subItems"
item-key="pain"
hide-actions
class="elevation-10">
<template slot="items" scope="props">
<td class="text-xs">{{ props.item.pain }}</td>
<td class="text-xs">{{ props.item.type }}</td>
</template>
</v-data-table>
</template>
</v-data-table>  </v-app>
</div>

//js goes here

export default {
name: 'accordion-table',
mounted () {
},
data () {
return {
mainHeaders: [
{ text: 'Medical informations', value: 'title' }
],
mainItems: [
{ title: 'Medical Checkup' },
{ title: 'Application connected' },
{ title: 'Programs' },
{ title: 'Pain List' }
],
subHeaders: [
{ text: 'Pain', value: 'pain' },
{ text: 'Type', value: 'type' }
],
subItems: [
{ pain: 'Knee', type: '1' },
{ pain: 'Ankle', type: '2' },
{ pain: 'Back', type: '3' },
{ pain: 'Neck', type: '4' }
]
}
}
}

(我使用了随机值) 希望对大家有所帮助

关于javascript - 如何通过 Accordion 显示数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54947219/

相关文章:

jsf - 如何以 Excel/CSV 格式导出 OpenFaces 数据表?

javascript - WordPress插件tinymce冲突

javascript - 组合折线图和条形图。我怎样才能渲染中间的线

WPF ListView 变得比它包含的 Canvas 更大

vue.js - 如何求和并将其显示在 vuetify 数据表中

javascript - VueJS csv 文件阅读器

css - 删除特定数据表上的所有边框

Javascript数组id显示顺序

javascript - 卡斯帕JS : clickLabel not working

javascript - Zapier-dalać 在 Action Fields (Custom) 字段中包含 u'