Skip to content

Improve the doc : components > slots #642

Open
@darkylmnx

Description

@darkylmnx

Hi,

there's a blur area in the docs about slots, in the guide (not API), we are not directly aware that there's a "$slots" variable (or others) available in the component's scope.

It would be really helpful to now this, use case :
conditionnal rendering of slots TAG wrapper. If we do not now we have access to "$slots" in the templates, this cannot be acheived, this is very important to slots as, you don't want your consumer to add unecessary tags when using the slot, he just needs to put his content.

<script>
  export default {
    props: ['title']
  }
</script>

<template>
  <header class="app-header">
    <div v-if="$slots.left" class="btns btns-left">
      <slot name="left"></slot>
    </div>
    <h1 class="title">{{ title }}</h1>
    <div v-if="$slots.right" class="btns btns-right">
      <slot name="right"></slot>
    </div>
  </header>
</template>

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions