现在我正在使用Vuetify.
当然,UI组件已经足够方便地包装.但是,我想重用一些带有自定义选项的组件.
特别是,我想重用数据表组件.
https://vuetifyjs.com/ja/components/data-tables
如果所有视图都具有完全相同的标题和数据,则没有问题.当每个视图具有不同的数据时,它不起作用.
这是我的代码:
Wrapper.vue
<template>
<v-card>
<v-card-title>
<span class="pr-3">{{ tableTitle }}</span>
<slot name="actions"/>
<v-spacer/>
<v-text-field
append-icon="search"
label="search"
single-line
hide-details
v-model="search"
/>
</v-card-title>
<v-data-table
:search="search"
:headers="headers"
:items="items"
hide-actions
>
<!-- problem is here! -->
<slot name="items" slot="items" slot-scope="props"></slot>
<template slot="expand" slot-scope="props">
<v-card flat>
<v-card-text>{{ props.item.note }}</v-card-text>
</v-card>
</template>
<template slot="no-data">
<v-alert :value="true" color="error" icon="warning">
no data.
</v-alert>
</template>
<template slot="no-results">
<v-alert :value="true" color="error" icon="warning">
no result.
</v-alert>
</template>
</v-data-table>
</v-card>
</template>
<script>
export default {
props: {
tableTitle: …Run Code Online (Sandbox Code Playgroud)