Answer the question
In order to leave comments, you need to log in
How to render content of slots manually?
There is a structure like this:
<parent>
<comp1 slot="foo"/>
<comp2 slot="bar"/>
<comp3 slot="qux"/>
</parent>
//parent.vue
this.$slots.foo
this.$slots.bar
this.$slots.qux
<component>
//parent.vue
<div v-for="data in dataset">
<component v-for="item in items" :is="$slots[item.slotname]" :data="data"/>
</div>
but I get an error:[Vue warn]: The "data" option should be a function that returns a per-instance value in component definitions. vue.runtime.esm.js:587
[Vue warn]: Failed to mount component: template or render function not defined.
:is
return a value from the attribute, render(h) => h(...)
but I can't correctly pass data to the component fromdataset
Answer the question
In order to leave comments, you need to log in
Can't it be easier?
// parent.vue
<template>
<slot name="foo"/>
<slot name="bar"/>
<slot name="qux"/>
</template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question