Search code examples
vue.jsvuejs3vue-component

Way to set items of b-table by parent component


I'm looking for a clean way to set items of b-table by parent component.

<ScrollableComponent ref="scrollTable" class="tableDiv">
   <b-table hover bordered no-border-collapse show-empty :items="This need to be set by ScrollableComponent"></b-table>
</ScrollableComponent>

I want to ScrollableComponent set items of b-table. I've tried something like that in ScrollableComponent but this doesn't work:

<div ref="scrollable-div" @scroll.passive="onScroll" @scrollend="onScroll">
   <slot :items="this.items"></slot>
</div>

Solution

  • Pass props to slots is not a good idea because slots (including default slot) from your page are readonly for ScrollableComponent.

    If you really want it, you can use Provide / Inject instead of props.