Last active
June 21, 2018 14:57
-
-
Save dabernathy89/e238ec22c2b27ad54c91cbca92c48e7d to your computer and use it in GitHub Desktop.
How to wrap a component that uses slots?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<v-server-table | |
:columns="columns" | |
:options="mergedOptions" | |
:name="tableName" | |
:ref="tableName"> | |
<template slot="beforeFilter"> | |
<slot name="beforeFilter"></slot> | |
</template> | |
<template slot="afterFilter"> | |
<slot name="afterFilter"></slot> | |
</template> | |
<template v-for="(slot, slot_name) in $slots"> | |
<template :slot="'h__' + slot_name.slice(13)" v-if="slot_name.indexOf('table-header-') === 0"> | |
<slot :name="slot_name"></slot> | |
</template> | |
</template> | |
<template v-for="(slot, slot_name) in $scopedSlots"> | |
<!-- This doesn't work 😭 --> | |
<template :slot="slot_name.slice(11)" slot-scope="props" v-if="slot_name.indexOf('table-cell-') === 0"> | |
<slot :name="slot_name" v-bind:row="props.row"></slot> | |
</template> | |
</v-server-table> |
@matthewtrask turns out that this works:
<template
v-for="(slot, slot_name) in $scopedSlots"
:slot="slot_name"
slot-scope="props">
<slot :name="slot_name" v-bind="props"></slot>
</template>
But this does not:
<template v-for="(slot, slot_name) in $scopedSlots">
<template
:slot="slot_name"
slot-scope="props">
<slot :name="slot_name" v-bind="props"></slot>
</template>
</template>
Guess it's just something internal to how Vue handles scoped slots ¯_(ツ)_/¯
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<!-- <slot :name="slot_name" v-bind:row="props.row"></slot> -->
This works though?