我有一個list和一個list_item組件,我可以在我的應用程序中重複使用很多。在一個簡單的形式:VueJS - 將子槽傳給子組件
contact_list.vue
<template lang="pug">
.table
.table-header.table-row
.table-col Contact
.table-col Info
.table-body
contact-list-item(v-for='contact in contacts',
:contact='contact',
@click='doSomething()')
</template>
contact_list_item.vue
<template lang="pug">
.table-row(@click='emitClickEvent')
.table-col {{ contact.name }}
.table-col {{ contact.info }}
</template>
當我使用CONTACT_LIST一個特定組成部分中,我希望能夠發送該插槽將向contact_list_item組件添加一些新列。此插槽將使用該contact_list_item組件內正在呈現的特定聯繫人的數據來生成新列。
我怎麼能做到這一點?使用插槽是最好的方法?
在此先感謝。