Answer the question
In order to leave comments, you need to log in
Is there a way to not output the contents of the slot by default?
There is a component that has several named slots.
One slot has default content. I don't need to render this slot in the component. But if I don't specify it, the default content will be inserted. You cannot opt out of the default content.
<!-- Компонент -->
<template>
<div>
<slot name="one">Контент по умолчанию</slot>
<slot name="two"></slot>
</div>
</template>
<!-- Родительский компонент -->
<template>
<div id="app">
<Component>
<!-- Содержимое v-slot:one выводится -->
<template v-slot:two>content</template>
</Component>
</div>
</template>
<template>
<div id="app">
<Component>
<template v-slot:one><div v-show="false"></div></template>
<template v-slot:two>content</template>
</Component>
</div>
</template>
Answer the question
In order to leave comments, you need to log in
<slot name="one" v-if="$slots.one"></slot>
<div v-else>Контент по умолчанию</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question