Skip to content

The v-slot directive breaks an example for functional components #2110

Open
@Justineo

Description

@Justineo

https://vuejs.org/v2/guide/render-function.html#slots-vs-children

With code example being:

<my-functional-component>
  <p v-slot:foo>
    first
  </p>
  <p>second</p>
</my-functional-component>

But v-slot is not allowed to be used on the element itself. It should be at least:

<my-functional-component>
  <template v-slot:foo>
    <p>first</p>
  </template>
  <p>second</p>
</my-functional-component>

Or to be more clear:

<my-functional-component>
  <template v-slot:foo>
    <p>first</p>
  </template>
  <template v-slot>
    <p>second</p>
  </template>
</my-functional-component>

But after updating to the valid syntax, the following part is not accurate anymore:

For this component, children will give you both paragraphs, slots().default will give you only the second, and slots().foo will give you only the first.

children won't give you both paragraphs, instead only those aren't wrapped inside the <template> element. I'm not sure how to re-organize this part actually.

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