Skip to content

Support ref attribute in slots #7661

@kanatkubash

Description

@kanatkubash

What problem does this feature solve?

When doing a composition of component like this:

Child component with slot

<template>
    <div>
        child
        <slot name="slot" ref="slot"/>
    </div>
</template>
<script>
    export default {
        name:'child'
    }
</script>

Parent component

<template>
    <div>
        parent
        <child>
            <custom-component slot="slot"/>
        </child>
    </div>
</template>
<script>
    import Child from './child.vue';
    import CustomComponent from 'custom-component';
    export default {
        name:'parent',
        components:{ Child, CustomComponent }
    }
</script>

it would be great to access custom-component (component not element ) using this.$refs.slot .
Currently its done using this statement this.$slots.slot[0].componentInstance , this.$refs.slot is undefined.

Use case is calling child slot component methods.

Thanks

What does the proposed API look like?

Accessing slot component using
this.$refs.slot

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