J
J
jazzus2020-02-28 08:55:50
Vue.js
jazzus, 2020-02-28 08:55:50

How to move the data for named slots into a separate module?

If I insert the data for the named slots into the component then everything works.

<template>
<span>
<template v-slot:top>
 top content
</template>

<template v-slot:buttons>
 buttons
</template>

<template v-slot:footer>
 footer content
</template>
</span>
</template>


now if I move some of the data into a new component
<template>
<span>
<slots>
</slots>

<template v-slot:footer>
 footer content
</template>
</span>
</template>

that doesn't work. can only appear at the root level inside the receiving component
Is there a way to put this data for the two slots into a separate part? It is necessary for use in other components and not duplicating code and so that it is not necessary to take out the content of slots in components. Those. for speed and simplicity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-02-28
@jazzus

No. A slot is part of the current component. But you can take out not the slots themselves, but their contents

<template>
  <span>
    <template v-slot:top>
      <top-content />
    </template>

    <template v-slot:buttons>
      <buttons />
    </template>

    <template v-slot:footer>
      footer content
    </template>
  </span>
</template>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question