我在 VueJS 2 中有一个案例,其中有一个 3 级组合的组件(祖父母 - 孩子 - 孙子),我需要将模板/插槽从祖父母向下传递给孙子(这是b-table
Bootstrap + Vue 库中的一个组件(https ://bootstrap-vue.js.org/docs/components/table))。
祖父组件:
<template>
<DataTable
:tableFields="postFields"
:tableService="posts"\
/>
</template>
<script>
export default {
name: 'Posts',
components: {
DataTable,
},
</script>
子组件:
<template>
<b-table
:items="items"
:fields="tableFields"
/>
</template>
<script>
export default {
name: 'Posts',
props: {
tableFields: {type: Array, required: true},
tableService: {type: Object, required: true},
},
components: {
DataTable,
},
</script>
孙子组件:
这个<b-table>
来自 Bootstrap + Vue ( https://bootstrap-vue.js.org/docs/components/table )
因此,正如 Bootstrap + Vue 文档所代表的那样,我可以将 a 传递<template>
给<b-table>
但我想首先将它从祖父母传递给孩子,然后从孩子传递给<b-table>
.