在v-for中使用带有插槽的组件

时间:2018-07-09 07:35:20

标签: vue.js components slot v-for

我需要在v-for循环中渲染一个带有插槽的组件,如下所示:

<div v-for="(data,index) in myList" :key="index">
    <datepicker v-model="data.thru">
        <div slot="beforeCalendarHeader" @click="selectToday" class="today p-2 text-center">
            Today
        </div>
    </datepicker>
</div>

我得到以下错误:

[Vue warn]: Duplicate presence of slot "beforeCalendarHeader" found in the same render tree - this will likely cause render errors.

我如何在循环内使用componentns插槽?

示例: https://codepen.io/DivDax/pen/ajoWPY

0 个答案:

没有答案