如何通过手风琴显示数据表

问题描述 投票:1回答:1

我在制作手风琴表时遇到了一些麻烦。我创建了一个Accordion组件和一个Table组件。虽然彼此独立,但它的工作完全正常,但我不能让任何桌子出现在手风琴中。

//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>

所以,重点是:我怎样才能使数据表出现在手风琴中?就像当你点击其中一个标题而它出现而不是一些文字?

非常感谢

javascript vue.js datatable accordion vuetify.js
1个回答
0
投票

解决!如果(如果人们遇到与我相同的问题),这里是代码(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' }
]
}
}
}

(我使用随机值)希望它对你们有些帮助

© www.soinside.com 2019 - 2024. All rights reserved.