Answer the question
In order to leave comments, you need to log in
How to pass the contents of a named slot to a child in a render function?
1) There is a component that, using the render function, displays another component:
export default {
name: "form-element",
render(h) {
let data = {
//.....................................
};
//.....................................
return h(component, data);
}
}
<form-element key="site">
<template slot="prepend-inner">
<img :src="`${form.site}/favicon.ico`">
</template>
</form-element>
Answer the question
In order to leave comments, you need to log in
Everything turned out to be simple, I share the solution.
You need to pass static slots as children (the third argument to createElement), and put the corresponding slot in the data of each child:
export default {
name: "form-element",
render(h) {
let data = {
//.....................................
};
//.....................................
let slots = []
for(let slot in this.$slots) {
slots.push(h('template', {slot}, this.$slots[slot]))
}
return h(component, data, slots);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question