您可以在 Table
元件中公開 cell
插槽,並在 App.vue
中使用它
<!-- Table.vue --> <template> <div class="table"> <template v-for="(row, rowI) in table.tree" :key="rowI"> <Row :row="row"> <template #cell="{ cell }"> <slot name="cell" :cell="cell"></slot> </template> </Row> <slot name="test" :id="rowI" /> </template> </div> </template>